# coding=utf-8

# 导入
# <editor-fold desc="Python：导入模块包">
# 操作系统
import os

# 输出效果
from yaspin import yaspin

# 时间
import time
from datetime import datetime, date, timedelta
import datetime

# 正则表达式
import re

# Appium
from appium import webdriver

# Selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from appium.webdriver.common.touch_action import TouchAction

# Android ADB
from ppadb.client import Client as AdbClient
# </editor-fold>

# 类

# <editor-fold desc="Tool">
class class_Tool():

    # 等待【多少】秒
    def time_do_wait(self, seconds_to_wait):
        with yaspin(text="等待【" + str(seconds_to_wait) + "】秒") as sp:
            for time_cursor in list(range(0, seconds_to_wait)):
                current_number = time_cursor + 1
                time.sleep(1)
                sp.write("--> 已等待【" + str(current_number) + "】秒")

            sp.green.ok("✔")

    # 创建目录
    def do_path(self, string_path):
        if not os.path.exists(string_path):
            os.makedirs(string_path)

    # 列出目录内容
    def list_path(self, string_path):
        if os.path.exists(string_path):
            return_data = os.listdir(string_path)

        return return_data

    # 写入文件
    def do_file(self, file_path, write_data, write_type):
        file_object = open(file=file_path, mode=write_type, encoding='utf-8')
        file_object.writelines(write_data)
        file_object.close()

    # 读文件
    def read_file(self, file_path, read_type):
        file_object = open(file=file_path, mode=read_type, encoding="utf-8")
        file_data = file_object.readlines()
        file_object.close()
        return file_data

# </editor-fold>

# <editor-fold desc="Android ADB">
class class_Android_ADB():

    def __init__(self, device_serial):
        # ADB 服务端的信息：IP 与 端口
        android_adb_client = AdbClient(host="127.0.0.1",
                                       port=5037)
        self.android_adb_session = android_adb_client.device(serial=device_serial)

    # 通过ADB在手机上执行命令
    def adb_do_shell(self, str_command):

        result_set = self.android_adb_session.shell(cmd=str_command)

        return result_set

    # 通过ADB在手机指定的路径中找到指定文件
    def adb_file_find(self, path, head_or_tail, counts):

        result_list = []

        if not path.endswith('/'):
            path = path + "/"

        str_command = "ls -ltr " + path + " | awk '{print $8}' | " + head_or_tail + " -n " + str(counts)

        result_set = self.adb_do_shell(str_command=str_command)

        for result_set_item in result_set.split('\n'):
            if result_set_item != "":
                current_result = path + result_set_item
                result_list.append(current_result)

        return result_list

    # 保存某个文件到PC的特定位置
    def adb_do_pull(self, source_list, pc_path):

        # 循环
        source_list_item_cursor = 1
        for source_list_item in source_list:

            # 变量
            if not pc_path.endswith("/"):
                pc_path = pc_path + "/"

            file_name = source_list_item[::-1].split("/")[0][::-1]
            target_item = pc_path + file_name

            # 显示
            # print("--- 保存 / [" + str(source_list_item_cursor) + "]")
            # print("原地址：" + source_list_item)
            # print("目标地址：" + target_item)

            self.android_adb_session.pull(
                src=source_list_item,
                dest=target_item
            )

            # 自增
            source_list_item_cursor = source_list_item_cursor + 1

# </editor-fold>

# <editor-fold desc="Appium">
class class_Appium():

    # 构造方法
    def __init__(self,device_serial):
        
        # APPIUM服务端的地址
        self.appium_server_address = "http://localhost:4723/wd/hub"

        self.appium_time_wait = 5

        self.appium_desired_caps = {}

        self.appium_desired_caps['platformName'] = "Android"
        self.appium_desired_caps['platformVersion'] = '10'
        self.appium_desired_caps['deviceName'] = device_serial

    # 执行某个appActivity动作
    def appium_driver(self, str_appActivity):

        self.appium_desired_caps['appActivity'] = str_appActivity

        self.appium_driver_object = webdriver.Remote(
            self.appium_server_address,
            self.appium_desired_caps
        )
        self.appium_driver_with_wait_object = WebDriverWait(
            self.appium_driver_object,
            self.appium_time_wait
        )

    # 【版本二】根据列表中的出现序号，找到某个父级对象下某个class的子集列表的第几个元素
    def appium_find_element_in_set_with_sequence_v2(self, Object_Set, which_one):

        # 返回值
        Return_Object = None

        Object_Set_cursor = 1
        for Object_Set_item in Object_Set:

            if Object_Set_cursor == which_one:
                Return_Object = Object_Set_item

            # 自增
            Object_Set_cursor = Object_Set_cursor + 1

        # 返回阶段
        return Return_Object

    # 【版本一】根据列表中的出现序号，找到某个父级对象下某个class的子集列表的第几个元素
    def appium_find_element_in_set_with_sequence(self, Start_Object, Class_Name, which_one):

        # 返回值
        Return_Object = None

        Start_Object_Set = self.appium_find_element_by_xpath(
            Start_Object=Start_Object,
            enable_Start_Object_class=True,
            one_or_more="more",
            str_xpath="/child::" + Class_Name
        )

        if Start_Object_Set is not None:
            Start_Object_Set_cursor = 1
            for Start_Object_Set_item in Start_Object_Set:

                if Start_Object_Set_cursor == which_one:
                    Return_Object = Start_Object_Set_item

                # 自增
                Start_Object_Set_cursor = Start_Object_Set_cursor + 1

        # 返回阶段
        return Return_Object

    # 根据element的属性的键值对查找【单个】元素
    def appium_find_element_by_key_value(self, key, value, Start_Object=None):

        # 返回值
        return_Obj = None

        try:
            # +++++++++++++++++++++++++++
            if Start_Object is not None:
                return_Obj = Start_Object.find_element_by_xpath(
                    '//*[@' + key + '="' + value + '"]'
                )
            else:
                return_Obj = self.appium_driver_with_wait_object.until(
                    EC.presence_of_element_located(
                        (By.XPATH,'//*[@' + key + '="' + value + '"]')
                    )
                )
            # +++++++++++++++++++++++++++
        except Exception as excp:
            pass

        # 返回阶段
        return return_Obj

    # 根据【XPATH】获取element【单个】对象 或者 对象【集合】
    def appium_find_element_by_xpath(self, str_xpath, one_or_more, Start_Object=None, enable_Start_Object_class=False):

        # 返回值
        Return_Object = None

        # 检索字符串
        str_patter = ""

        try:
            # -----------------------------------------
            if Start_Object is None:
                # 起始元素【空】

                # 检索字符串
                str_patter = str_xpath

                if one_or_more == "one":
                    Return_Object = self.appium_driver_with_wait_object.until(
                        EC.presence_of_element_located(
                            (By.XPATH, str_patter)
                        )
                    )
                elif one_or_more == "more":
                    Return_Object = self.appium_driver_with_wait_object.until(
                        EC.presence_of_all_elements_located(
                            (By.XPATH, str_patter)
                        )
                    )

            else:
                # 起始元素【非空】

                if enable_Start_Object_class == True:
                    Start_Object_class = self.appium_element_get_attribute_CLASS(
                        Start_Object
                    )

                    # 检索字符串
                    str_patter = "//" + Start_Object_class + str_xpath
                else:
                    str_patter = str_xpath

                if one_or_more == "one":
                    Return_Object = Start_Object.find_element_by_xpath(
                        str_patter
                    )
                elif one_or_more == "more":
                    Return_Object = Start_Object.find_elements_by_xpath(
                        str_patter
                    )
            # -----------------------------------------
        except Exception as excp:
            pass

        # 返回阶段
        return Return_Object

    # 显示【元素】对象集合的内容
    def appium_elements_display(self, Start_Object):

        if Start_Object is None:
            # print(" !!!! 当前【元素】对象集合【为空】 !!!! ")
            pass

        else:
            Start_Object_cursor = 1
            for Start_Object_item in Start_Object:
                # 属性
                Start_Object_resource_id = self.appium_element_get_attribute_RESOURCE_ID(
                    Start_Object_item
                )
                Start_Object_text = self.appium_element_get_attribute_TEXT(
                    Start_Object_item
                )
                Start_Object_class = self.appium_element_get_attribute_CLASS(
                    Start_Object_item
                )
                Start_Object_content_desc = self.appium_element_get_attribute_CONTENT_DESC(
                    Start_Object_item
                )

                # 显示
                # print("--------- 【" + str(Start_Object_cursor) + "】")
                # print("Resource-id / " + Start_Object_resource_id)
                # print("Class / " + Start_Object_class)
                # print("Text / " + Start_Object_text)
                # print("Content-text / " + Start_Object_content_desc)

                # 自增
                Start_Object_cursor = Start_Object_cursor + 1

    # 向文本element中写入值
    def appium_element_input_value(self, target_object, str_value):

        target_object.send_keys(str_value)

    # 获取对象属性【class】
    def appium_element_get_attribute_CLASS(self, target_object):

        # 返回值
        data_return = "<<Empty_Class | INIT>>"

        # 处理逻辑
        if target_object is not None:
            data_return = target_object.get_attribute("class")

        # 返回阶段
        return data_return

    # 获取对象属性【text】
    def appium_element_get_attribute_TEXT(self, target_object):

        # 返回值
        data_return = "<<Empty_Text | INIT>>"

        # 处理逻辑
        if target_object is not None:
            try:
                data_return = target_object.get_attribute("text")
            except Exception as excp:
                pass
            if data_return == "" or data_return is None:
                data_return = "<<Empty>>"

        # 返回阶段
        return data_return

    # 获取对象属性【resource-id】
    def appium_element_get_attribute_RESOURCE_ID(self, target_object):

        # 返回值
        data_return = "<<Empty_Resource_id | INIT>>"

        # 处理逻辑
        if target_object is not None:

            try:
                data_return = target_object.get_attribute("resourceId")
            except Exception as excp:
                pass

            if data_return == "" or data_return is None:
                data_return = "<<Empty>>"

        # 返回阶段
        return data_return

    # 获取对象属性【content-desc】
    def appium_element_get_attribute_CONTENT_DESC(self, target_object):

        # 返回值
        data_return = "<<Empty_Content_Desc | INIT>>"

        # 处理逻辑
        if target_object is not None:
            data_return = target_object.get_attribute("content-desc")

            if data_return == "" or data_return is None:
                data_return = "<<Empty>>"

        # 返回阶段
        return data_return

    # 滑动屏幕
    def appium_swipe(self, swipe_count, swipe_duration, start_x, start_y, end_x, end_y):
        for swipe_count_current in range(swipe_count):
            # 宣告
            # print("")
            # print(" 【滑动屏幕】 (C)" + str(swipe_count_current) + "/(T)" + str(swipe_count))
            # print(" --- Start：" + str(start_x) + " / " + str(start_y))
            # print(" --- End：" + str(end_x) + " / " + str(end_y))
            # print("")

            # 执行：滑动
            try:
                self.appium_driver_object.swipe(start_x, start_y, end_x, end_y, swipe_duration)
            except Exception as excp:
                pass

    # 上一次点击是否成功
    def appium_isExsist_class_name(self, class_name):

        # 返回值
        data_return = ""

        # @@@@@@@@@@@@@@@@@@@@@ 第一次点击是否成功
        click_isOk = self.appium_find_element_by_key_value(
            key="class",
            value=class_name
        )

        if click_isOk is None:
            # print(" #### 目标类型元素【存在】 ####")

            # @@@ pass
            pass

        else:
            # print(" #### 目标类型元素【不存在】 ####")

            data_return = "Error"

            # 返回阶段
            return data_return
        # @@@@@@@@@@@@@@@@@@@@@ 第一次点击是否成功

        # 返回阶段
        return data_return

# </editor-fold>

# <editor-fold desc="微信">
class class_WeChat():

    def __init__(self):

        device_serial = "你的设备的序列号"

        self.object_Appium = class_Appium(device_serial=device_serial)
        self.object_Appium.appium_desired_caps['appPackage'] = "com.tencent.mm"

        self.wechat_account_name = "你的微信账号"
        self.wechat_account_password = "你的微信密码"

        self.path_wechat_phone = "/storage/emulated/0/tencent/MicroMsg/WeiXin/"
        # 你在PC上存放微信朋友圈数据的路径
        self.path_wechat_pc_root = "D:/android_download/"

        self.object_Tool = class_Tool()
        self.object_Android_ADB = class_Android_ADB(device_serial=device_serial)

        # ---> 全局参数定义

        # 滑动参数
        self.wechat_swipe_start_x = 300
        self.wechat_swipe_start_y = 1200
        self.wechat_swipe_end_x = 300
        self.wechat_swipe_end_y = 500

        # 朋友圈作者信息
        self.info_wechat_name = ""
        self.info_wechat_nick_name = "你要爬取的微信号码的昵称"

        # 朋友圈上一次单页爬取的元素的id列表
        self.list_wechat_current_page_element_id = []
        self.list_wechat_before_page_element_id = []

        # 朋友圈 / 日期列表
        self.list_wechat_current_record_time_create = []
        self.list_wechat_before_record_time_create = []
        self.list_wechat_init_record_time_create = []
        self.list_wechat_init_record_time_create_v2 = []

        # 朋友圈 / 总列表 / 日期数据
        # -- 默认从当前时间开始
        time = datetime.datetime.now().timetuple()
        self.Date_before_year = str(time.tm_year) + '年'
        self.Date_before_month_and_day = str(time.tm_mon) + '月' + str(time.tm_mday) + '日'

        # 微信爬取开始时间
        self.python_start_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        # 朋友圈某个记录是否读到了日期数据
        self.Record_isExsist_Date_Formate_String = False

        # 是否：找到了【朋友圈：头部】
        self.isDone_WeChat_Header = False

    # 微信：打开
    def wechat_launch(self, session_keep=True):

        if session_keep:
            self.object_Appium.appium_desired_caps['noReset'] = True
        else:
            self.object_Appium.appium_desired_caps['noReset'] = False

        self.object_Appium.appium_driver(str_appActivity='.ui.LauncherUI')

    # 微信：登录
    def wechat_login(self):

        # 等待
        self.object_Tool.time_do_wait(seconds_to_wait=12)

        # )))))))))))))))))))
        login_1_obj = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="登录"
        )
        login_1_obj.click()
        # )))))))))))))))))))
        login_2_obj = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="用微信号/QQ号/邮箱登录"
        )
        login_2_obj.click()
        # )))))))))))))))))))
        login_3_obj_1 = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="请填写微信号/QQ号/邮箱"
        )
        self.object_Appium.appium_element_input_value(
            target_object=login_3_obj_1,
            str_value=self.wechat_account_name
        )

        login_3_obj_2 = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="请填写密码"
        )
        self.object_Appium.appium_element_input_value(
            target_object=login_3_obj_2,
            str_value=self.wechat_account_password
        )

        login_3_obj_3 = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="登录"
        )
        login_3_obj_3.click()
        # )))))))))))))))))))
        login_4_obj = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="我知道了"
        )
        login_4_obj.click()
        # )))))))))))))))))))
        login_5_obj_1 = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="允许"
        )
        login_5_obj_1.click()

        login_5_obj_2 = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="允许"
        )
        login_5_obj_2.click()
        # )))))))))))))))))))
        # print("是否允许查看手机通讯录")
        login_6_obj = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="否"
        )
        login_6_obj.click()
        # )))))))))))))))))))
        # 等待 / 等待微信加载过程
        # --- 可能有点长 / 按照实际情况去设置等待
        self.object_Tool.time_do_wait(seconds_to_wait=52)

        login_7_obj = self.object_Appium.appium_find_element_by_key_value(
            key='text',
            value="暂不设置"
        )
        login_7_obj.click()
        # )))))))))))))))))))

    # 微信：朋友圈
    # --- 进入【某人】的朋友圈
    def wechat_moment(self, someone_name):

        # 赋值到类变量
        self.info_wechat_name = someone_name

        # 重置保存位置
        self.path_wechat_pc_root = self.path_wechat_pc_root + someone_name
        self.object_Tool.do_path(string_path=self.path_wechat_pc_root)

        # 判断当前已经抓取的，并且将结果放到前置列表【self.list_wechat_before_record_time_create】中，以便于后续结果中，逻辑跳过
        self.list_wechat_init_record_time_create = self.object_Tool.list_path(string_path=self.path_wechat_pc_root)

        # 生成第二版的初始列表
        for list_item in self.list_wechat_init_record_time_create:
            current_item = list_item.split("_")[0]

            if current_item not in self.list_wechat_init_record_time_create_v2:
                self.list_wechat_init_record_time_create_v2.append(current_item)

        # )))))))))))))))))))
        moment_1_obj = self.object_Appium.appium_find_element_by_key_value(
            key="content-desc",
            value="搜索"
        )
        moment_1_obj.click()
        # )))))))))))))))))))
        moment_2_obj = self.object_Appium.appium_find_element_by_key_value(
            key="text",
            value="搜索"
        )
        self.object_Appium.appium_element_input_value(
            target_object=moment_2_obj,
            str_value=someone_name
        )

        # 等待
        self.object_Tool.time_do_wait(seconds_to_wait=12)

        # )))))))))))))))))))
        moment_3_obj_1 = self.object_Appium.appium_find_element_by_key_value(
            key="text",
            value="联系人"
        )
        moment_3_obj_2 = self.object_Appium.appium_find_element_by_key_value(
            key="text",
            value="最常使用"
        )

        if moment_3_obj_1 is None and moment_3_obj_2 is None:
            # print("无法【直接】找到联系人 / 需要进一步【搜索】")

            # 定位字符
            str_patter = "查找微信号:" + someone_name

            moment_3_obj_1 = self.object_Appium.appium_find_element_by_key_value(
                key="text",
                value=str_patter
            )

            moment_3_obj_1.click()

        else:
            # print("已经【找到了】联系人")

            # 定位字符
            str_patter = "微信号: " + someone_name

            moment_3_obj_2 = self.object_Appium.appium_find_element_by_key_value(
                key="class",
                value="android.widget.ListView"
            )

            # +++++++++++++
            # moment_3_obj_2_child_1 = self.object_Appium.appium_find_element_by_xpath(
            #     Start_Object=moment_3_obj_2,
            #     str_xpath="/child::android.widget.RelativeLayout",
            #     one_or_more="more"
            # )
            # moment_3_obj_2_child_1_len = len(moment_3_obj_2_child_1)
            # print("ListView / 子集长度：" + str(moment_3_obj_2_child_1_len))
            # +++++++++++++

            moment_3_obj_2_child_1_str_patter = \
                "//*/android.widget.TextView[@text='" + str_patter + "']" + \
                    "/parent::android.widget.LinearLayout" + \
                        "/parent::android.widget.LinearLayout" + \
                            "/parent::android.widget.RelativeLayout"

            moment_3_obj_2_child_1 = self.object_Appium.appium_find_element_by_xpath(
                one_or_more="one",
                str_xpath=moment_3_obj_2_child_1_str_patter,
                Start_Object=moment_3_obj_2,
                enable_Start_Object_class=False
            )

            # 找到昵称
            # ========================
            moment_3_obj_2_child_1_nick_name_str_patter = "//*/android.widget.TextView[@text='" + str_patter + "']" + \
                            "/parent::android.widget.LinearLayout" + \
                            "//following-sibling::android.widget.TextView"

            moment_3_obj_2_child_1_nick_name = self.object_Appium.appium_find_element_by_xpath(
                one_or_more="one",
                str_xpath=moment_3_obj_2_child_1_nick_name_str_patter,
                Start_Object=moment_3_obj_2,
                enable_Start_Object_class=False
            )
            moment_3_obj_2_child_1_nick_name_text = self.object_Appium.appium_element_get_attribute_TEXT(
                moment_3_obj_2_child_1_nick_name
            )
            self.info_wechat_nick_name = moment_3_obj_2_child_1_nick_name_text
            print("昵称为：【" + self.info_wechat_nick_name + "】")
            # ========================
            # 执行：点击
            moment_3_obj_2_child_1.click()
            # )))))))))))))))))))
            moment_4_obj = self.object_Appium.appium_find_element_by_key_value(
                key="content-desc",
                value="聊天信息"
            )
            moment_4_obj.click()
            # )))))))))))))))))))
            moment_5_obj_image_button_str_patter = \
                "//*/android.widget.TextView[@text='" + self.info_wechat_nick_name + "']" + \
                                    "/parent::android.widget.RelativeLayout"

            moment_5_obj_image_button = self.object_Appium.appium_find_element_by_xpath(
                one_or_more="one",
                str_xpath=moment_5_obj_image_button_str_patter,
                enable_Start_Object_class=False
            )
            moment_5_obj_image_button.click()
            # )))))))))))))))))))
        moment_6_obj_image_button_str_patter = \
            "//*/android.widget.TextView[@text='朋友圈']" + \
            "/parent::android.widget.LinearLayout"

        moment_6_obj_image_button = self.object_Appium.appium_find_element_by_xpath(
            one_or_more="one",
            str_xpath=moment_6_obj_image_button_str_patter,
            enable_Start_Object_class=False
        )
        moment_6_obj_image_button.click()
        # )))))))))))))))))))
        # )))))))))))))))))))

    # 微信【朋友圈】--> 引用【单页】+【滑动屏幕】
    def wechat_moment_single_page_and_swipe(self):

        # While循环的判断值
        while_Condition = True

        # 匹配到Finished几次？
        finished_count = 0

        # 循环
        while_cursor = 1
        while while_Condition:

            # 宣告当前轮次
            # print("")
            # print("######################")
            # print("当前【" + str(while_cursor) + "】")
            # print("######################")
            # print("")

            # @@@@@@@@@@@@@@@@@@@@@@@
            ListView_Obj = self.object_Appium.appium_find_element_by_key_value(
                key="class",
                value="android.widget.ListView"
            )
            if ListView_Obj is None:
                # print(" !!!!!!! 对象【ListView_Obj】【空】 !!!!!!! ")
                while_cursor = while_cursor + 1
                continue
            else:
                # print(" @@@@@@@@@ 对象【ListView_Obj】【非空】 @@@@@@@@@ ")
                pass
            # @@@@@@@@@@@@@@@@@@@@@@@
            # 单页分析
            result = self.wechat_moment_single_page()

            if result == "skip":
                # 自增
                while_cursor = while_cursor + 1
                # 跳过
                continue

            if result == "finished":
                # 表示，单页已经找到了全部朋友圈记录的最后一条
                print("单页已经找到了全部朋友圈记录的最后一条")

                # 自增
                while_cursor = while_cursor + 1
                finished_count = finished_count + 1

            else:
                finished_count = 0

            if finished_count > 3:

                # 结束
                break

            # @@@@@@@@@@@@@@@@@@@@@@@
            # 滑动

            self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                     start_x=self.wechat_swipe_start_x, start_y=self.wechat_swipe_start_y,
                                     end_x=self.wechat_swipe_end_x, end_y=self.wechat_swipe_end_y)

            # @@@@@@@@@@@@@@@@@@@@@@@
            # 检查是否有【正在加载】

            try:
                Loading_Object = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=ListView_Obj,
                    enable_Start_Object_class=True,
                    one_or_more="one",
                    str_xpath="/child::android.widget.LinearLayout[last()]"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.TextView"
                )

                TextView_Level_Object = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=ListView_Obj,
                    enable_Start_Object_class=True,
                    one_or_more="more",
                    str_xpath="/child::android.widget.LinearLayout[last()]"
                              "/child::android.widget.LinearLayout[last()]"
                              "/child::android.widget.LinearLayout[last()]"
                              "/child::*"
                )

                TextView_Level_Object_len = len(TextView_Level_Object)

                # print("TextView_Level_Object_len / " + str(TextView_Level_Object_len))

                Loading_Object_cursor = 1
                while Loading_Object is not None:

                    # 属性
                    Loading_Object_text = self.object_Appium.appium_element_get_attribute_TEXT(Loading_Object)

                    # 显示
                    # print("@@@@ 加载对象 / 文本：" + Loading_Object_text)

                    if Loading_Object_text == "正在加载..." and TextView_Level_Object_len == 2:
                        # 宣告
                        print("出现【正在加载...】 / 【" + str(Loading_Object_cursor) + "】")

                        # 重新滑动
                        self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                        start_x=self.wechat_swipe_start_x, start_y=self.wechat_swipe_start_y,
                                                        end_x=self.wechat_swipe_end_x, end_y=self.wechat_swipe_end_y)
                    else:
                        # 如果不是【目标】就退出while循环
                        break

                    # 等待
                    self.object_Tool.time_do_wait(seconds_to_wait=5)

                    # 再次检查
                    Loading_Object = self.object_Appium.appium_find_element_by_xpath(
                        Start_Object=ListView_Obj,
                        enable_Start_Object_class=True,
                        one_or_more="one",
                        str_xpath="/child::android.widget.LinearLayout[last()]"
                                  "/child::android.widget.LinearLayout"
                                  "/child::android.widget.LinearLayout"
                                  "/child::android.widget.TextView"
                    )

                    TextView_Level_Object = self.object_Appium.appium_find_element_by_xpath(
                        Start_Object=ListView_Obj,
                        enable_Start_Object_class=True,
                        one_or_more="more",
                        str_xpath="/child::android.widget.LinearLayout[last()]"
                                  "/child::android.widget.LinearLayout[last()]"
                                  "/child::android.widget.LinearLayout[last()]"
                                  "/child::*"
                    )

                    TextView_Level_Object_len = len(TextView_Level_Object)

                    # print("TextView_Level_Object_len / " + str(TextView_Level_Object_len))

                    # 自增
                    Loading_Object_cursor = Loading_Object_cursor + 1

            except Exception as excp:
                pass

            # 等待
            # self.object_Tool.time_do_wait(seconds_to_wait=10)

            # 自增
            while_cursor = while_cursor + 1

        # 循环结束

    # 微信【朋友圈】--> 【单页】
    def wechat_moment_single_page(self):

        # 返回值
        data_return = ""

        # 清空当前单页爬取元素列表
        self.list_wechat_current_page_element_id = []
        self.list_wechat_current_record_time_create = []

        SinglePage_ListView_child_1 = None
        while SinglePage_ListView_child_1 is None:
            SinglePage_ListView = self.object_Appium.appium_find_element_by_key_value(
                key="class",
                value="android.widget.ListView"
            )

            SinglePage_ListView_child_1 = self.object_Appium.appium_find_element_by_xpath(
                Start_Object=SinglePage_ListView,
                enable_Start_Object_class=True,
                one_or_more="more",
                str_xpath="/child::android.widget.LinearLayout"
            )

        SinglePage_ListView_child_1_len = len(SinglePage_ListView_child_1)

        # print("当前页【ListView】一级子集 / 长度：" + str(SinglePage_ListView_child_1_len))

        # 循环
        SinglePage_ListView_child_1_cursor = 1
        for SinglePage_ListView_child_1_len_item in range(SinglePage_ListView_child_1_len):

            # 宣告
            print("")
            print("===================================")
            print("[单页] ---> 当前【" + str(SinglePage_ListView_child_1_cursor) + " / " + str(
                SinglePage_ListView_child_1_len) + "】")
            print("===================================")

            Top_ListView = self.object_Appium.appium_find_element_by_key_value(
                key="class",
                value="android.widget.ListView"
            )

            if Top_ListView is None:
                print("对象【Top_ListView】为空")

                Top_ListView_cursor = 1
                while Top_ListView is None:
                    Top_ListView = self.object_Appium.appium_find_element_by_key_value(
                        key="class",
                        value="android.widget.ListView"
                    )
                    # 显示
                    print(" ---> 对象【Top_ListView】/ 查找【" + str(Top_ListView_cursor) + "】次")
                    # 自增
                    Top_ListView_cursor = Top_ListView_cursor + 1

            else:
                print("对象【Top_ListView】非空")

            Top_ListView_Child = self.object_Appium.appium_find_element_in_set_with_sequence(
                Start_Object=Top_ListView,
                Class_Name="android.widget.LinearLayout",
                which_one=SinglePage_ListView_child_1_cursor
            )

            Top_ListView_Child_resource_id = ""
            SinglePage_ListView_child_1_item = None

            if Top_ListView_Child is not None:
                Top_ListView_Child_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(Top_ListView_Child)
                SinglePage_ListView_child_1_item = Top_ListView_Child

            # 宣告
            print("---> resource-id / " + Top_ListView_Child_resource_id)

            print("——————————————")
            print("【开始】时间：" + self.python_start_time)
            print("【当前】时间：" + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
            print("")

            if SinglePage_ListView_child_1_item is None:

                # print(" !!!!!!! 对象【SinglePage_ListView_child_1_item】【空】 !!!!!!! ")

                # 自增
                SinglePage_ListView_child_1_cursor = SinglePage_ListView_child_1_cursor + 1

                # 跳过
                continue

            else:

                # print(" @@@@ 对象【SinglePage_ListView_child_1_item】【非空】  ")
                pass

            # # 是否是朋友圈头部
            # if Top_ListView_Child_resource_id == "<<Empty>>" and not self.isDone_WeChat_Header:
            #     # 朋友圈头部
            #     print("@@@@ 朋友圈【头部】 @@@@")
            #
            #     self.wechat_moment_part_head(SinglePage_ListView_child_1_item)
            #
            #     # 重置
            #     self.isDone_WeChat_Header = True

            # @@@@@@@@@@@@@@@@
            # 跳过
            # @@@@@@@@@@@@@@@@

            # 当前单页最后一项
            if SinglePage_ListView_child_1_cursor == SinglePage_ListView_child_1_len:

                # 当前位于最后一项，并且resource-id为空
                # 当前是整体朋友圈记录的最后一条
                if Top_ListView_Child_resource_id == "<<Empty>>":

                    data_return = "finished"

                    return data_return

                # 普通的最后一条记录
                print("---> 当前位于【单页】的【最后一条记录】 / 跳过")
                print("")

                # 列表处理

                self.list_wechat_before_page_element_id = self.list_wechat_current_page_element_id
                self.list_wechat_before_record_time_create = self.list_wechat_current_record_time_create

                # 自增
                SinglePage_ListView_child_1_cursor = SinglePage_ListView_child_1_cursor + 1

                # 跳过
                continue

            # @@@@@@@@@@@@@@@@
            # 真正的处理
            # @@@@@@@@@@@@@@@@

            Record_status = "Done"

            # Old
            Record_status = self.wechat_moment_record_index(Record_Object=SinglePage_ListView_child_1_item)

            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
            if Record_status == "skip":

                # 宣告
                print("")
                print("@@@ 跳过当前记录 @@@")
                print("")

                # 自增
                SinglePage_ListView_child_1_cursor = SinglePage_ListView_child_1_cursor + 1

                # 跳过
                continue

            # @@@@@@@@@@@@@@@@
            # 自增
            # @@@@@@@@@@@@@@@@

            SinglePage_ListView_child_1_cursor = SinglePage_ListView_child_1_cursor + 1

        # 返回阶段
        return data_return

    # 微信【朋友圈】--> 【单条记录】在【单页】的分析
    def wechat_moment_record_index(self, Record_Object):

        # 返回值
        data_return = "Done"

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 判断整体日期 / 开始
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 日期对象

        # ---- 年
        Date_Object_Year = self.object_Appium.appium_find_element_by_xpath(
            Start_Object=Record_Object,
            enable_Start_Object_class=True,
            one_or_more="one",
            str_xpath="/child::android.widget.LinearLayout[2]"
                      "/child::android.widget.TextView"
        )
        Date_current_year = ""
        if Date_Object_Year is None:
            Date_current_year = ""
        else:
            Date_Object_Year_text = self.object_Appium.appium_element_get_attribute_TEXT(Date_Object_Year)
            if re.match("[0-9]{4}年$", Date_Object_Year_text):
                Date_current_year = Date_Object_Year_text

        print("****************")
        print("【当前】日期对象 | 年：" + Date_current_year)
        print("****************")

        # ---- 月和日
        Date_Object_Month_and_Day_len = ""
        Date_Object_Month_and_Day = None
        while Date_Object_Month_and_Day is None:
            Date_Object_Month_and_Day = self.object_Appium.appium_find_element_by_xpath(
                Start_Object=Record_Object,
                enable_Start_Object_class=True,
                one_or_more="more",
                str_xpath="/child::android.widget.LinearLayout[last()]"
                          "/child::android.widget.LinearLayout[1]"
                          "/child::android.widget.LinearLayout"
                          "/child::android.widget.LinearLayout"
                          "/child::android.widget.TextView"
                )

        Date_Object_Month_and_Day_len = len(Date_Object_Month_and_Day)

        print("记录【日期部分】长度：" + str(Date_Object_Month_and_Day_len))

        Date_current_month_and_day = ""
        list_Date_current_month_and_day = []

        for Date_Object_Month_and_Day_item in Date_Object_Month_and_Day:

            Date_Object_Month_and_Day_item_text = self.object_Appium.appium_element_get_attribute_TEXT(
                Date_Object_Month_and_Day_item
            )

            print("---> 当前循环到的值为：" + Date_Object_Month_and_Day_item_text)

            if Date_Object_Month_and_Day_len == 1:
                if Date_Object_Month_and_Day_item_text == "今天":
                    time = datetime.datetime.now().timetuple()
                    VersionInfo = str(time.tm_mon) + '月' + str(time.tm_mday) + '日'
                    Date_current_month_and_day = VersionInfo

                if Date_Object_Month_and_Day_item_text == "昨天":
                    time = (date.today() + timedelta(days=-1)).timetuple()
                    VersionInfo = str(time.tm_mon) + '月' + str(time.tm_mday) + '日'
                    Date_current_month_and_day = VersionInfo

            else:

                if Date_Object_Month_and_Day_item_text.isdigit():
                    list_Date_current_month_and_day.append(Date_Object_Month_and_Day_item_text)

                if re.match("[0-9]{1,2}月$", Date_Object_Month_and_Day_item_text):
                    list_Date_current_month_and_day.append(Date_Object_Month_and_Day_item_text)

        print("****************")
        print("【当前】日期对象 | 月 与 日 / 原始队列：" + str(list_Date_current_month_and_day))
        print("****************")

        Date_current_month = ""
        Date_current_day = ""

        if len(list_Date_current_month_and_day) != 0:

            if len(list_Date_current_month_and_day) == 1:

                if list_Date_current_month_and_day[0].isdigit():
                    Date_current_day = list_Date_current_month_and_day[0]

                if re.match("[0-9]{1,2}月", list_Date_current_month_and_day[0]):
                    Date_current_month = list_Date_current_month_and_day[0]

                if Date_current_day == "":
                    Date_current_day = self.Date_before_month_and_day.split("月")[1].split("日")[0]

                if Date_current_month == "":
                    Date_current_day = self.Date_before_month_and_day.split("月")[0]

                Date_current_month_and_day = Date_current_month + "月" + Date_current_day + "日"

            if len(list_Date_current_month_and_day) == 2:
                Date_current_month_and_day = list_Date_current_month_and_day[1] + list_Date_current_month_and_day[0].lstrip("0") + "日"

        else:
            if Date_current_month_and_day == "":
                Date_current_month_and_day = self.Date_before_month_and_day

        print("****************")
        print("【当前】日期对象 | 月 与 日：" + Date_current_month_and_day)
        print("****************")

        # -- 年
        # 获取当前真正的判定值
        if Date_current_year == "":
            Date_current_year = self.Date_before_year

        Date_current_full = Date_current_year + Date_current_month_and_day

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # 处理日的数据
        # --- month
        Date_current_full_part_Month = Date_current_full.split("年")[1].split('月')[0]
        Date_current_full_part_Month_new = ""

        if len(Date_current_full_part_Month) == 1:
            Date_current_full_part_Month_new = "0" + Date_current_full_part_Month
        else:
            if Date_current_full_part_Month.startswith("0"):
                # Date_current_full_part_Month_new = Date_current_full_part_Month.lstrip("0")
                Date_current_full_part_Month_new = str(int(Date_current_full_part_Month))
            else:
                Date_current_full_part_Month_new = Date_current_full_part_Month

        # --- day
        Date_current_full_part_Day = Date_current_full.split("月")[1].split('日')[0]
        Date_current_full_part_Day_new = ""

        if len(Date_current_full_part_Day) == 1:
            Date_current_full_part_Day_new = "0" + Date_current_full_part_Day
        else:
            if Date_current_full_part_Day.startswith("0"):
                Date_current_full_part_Day_new = Date_current_full_part_Day.lstrip("0")
            else:
                Date_current_full_part_Day_new = Date_current_full_part_Day

        # --- Full
        Date_current_full_new = Date_current_full.split("年")[0] + "年" + Date_current_full_part_Month_new + "月" + Date_current_full_part_Day_new + "日"

        print("****************")
        print("【整合后】日期对象：" + Date_current_full + " | " + Date_current_full_new)
        print("****************")

        print("比对列表 / 长度：" + str(len(self.list_wechat_init_record_time_create_v2)))
        print("****************")
        print(self.list_wechat_init_record_time_create_v2)
        print("****************")

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 回写阶段
        self.Date_before_year = Date_current_year
        self.Date_before_month_and_day = Date_current_month_and_day

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 判定阶段
        if self.isDone_WeChat_Header:
            print("朋友圈【头部】已经分析过了")
            if Date_current_full in self.list_wechat_init_record_time_create_v2 \
                or Date_current_full_new in self.list_wechat_init_record_time_create_v2:
                print("当前记录 / 已经被【保存过】 ---> 跳过")
                data_return = "skip"
                return data_return
        else:
            print("朋友圈【头部】 / 【还没有】分析过了")

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 判断整体日期 / 结束
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 判断是否存在【两条包含图片】的记录位于同一行的情况
        # <editor-fold desc="子集 / View对象">

        # Old
        # Record_Object_child_class_View = Record_Object.find_elements_by_class_name(
        #     "android.view.View"
        # )

        # New
        Record_Object_child_class_View = Record_Object.find_elements_by_xpath(
                    '//*[@content-desc="图片"]'
                )

        if Record_Object_child_class_View is None:
            # print("对象【SinglePage_ListView_child_1_item_view】为空")
            pass

        # -- 长度
        Record_Object_child_class_View_len = len(Record_Object_child_class_View)

        # print("@@@@@@@@@@@@@@@@@@@@@ 【朋友圈】总列表 / 单行包含的【View】/ 数量：" + str(Record_Object_child_class_View_len))
        # </editor-fold>

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        Record_Object_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(
            Record_Object
        )
        print("@@--->>>> 【Record_Object】resource-id / " + Record_Object_resource_id)
        Record_Object_location_y = Record_Object.location.get('y')

        if Record_Object_resource_id == "<<Empty>>":

            # Old

            # 宣告
            print("@@@@ 朋友圈【头部】 @@@@")

            if not self.isDone_WeChat_Header:
                # 头部分析函数
                self.wechat_moment_part_head(Start_Object=Record_Object)

                # 重置头部判定标记
                self.isDone_WeChat_Header = True

        else:

            if Record_Object_location_y < 189:

                print("!!!! 元素【Y轴】坐标过小 !!!!")

                # 重置：返回值
                data_return = "skip"

                # 返回阶段
                return data_return

            else:

                Photograph_Object = self.object_Appium.appium_find_element_by_key_value(
                    Start_Object=Record_Object,
                    key="content-desc",
                    value="拍照分享"
                )

                if Photograph_Object is not None:
                    print("@@@@ 朋友圈【拍照分享】 @@@@")

                    # 重置：返回值
                    data_return = "skip"

                    # 返回阶段
                    return data_return

                else:
                    print("@@@@ 朋友圈【正常内容】 @@@@")

                    print("【Record_Object_child_class_View_len】：" + str(Record_Object_child_class_View_len))
                    if Record_Object_child_class_View_len > 1:

                        # print("朋友圈【总表】当前行 / 包含多个【图片】记录")

                        Record_Object_child_class_View_len_cursor = 1
                        for Record_Object_child_class_View_len_item in range(Record_Object_child_class_View_len):

                            Record_Object_child_class_View_item = self.object_Appium.appium_find_element_in_set_with_sequence_v2(
                                Object_Set=Record_Object_child_class_View,
                                which_one=Record_Object_child_class_View_len_cursor
                            )

                            Record_Object_child_class_View_item_clickable = ""
                            if Record_Object_child_class_View_item is not None:
                                # --- 属性
                                Record_Object_child_class_View_item_clickable = Record_Object_child_class_View_item.get_attribute("clickable")

                            # print("元素对象【view】/ clickable / " + Record_Object_child_class_View_item_clickable)

                            if Record_Object_child_class_View_item_clickable == "true":

                                # 【记录】动作流函数
                                result_status = self.wechat_moment_record_action_flow(
                                    Start_Object=Record_Object_child_class_View_item
                                )

                                if result_status == "Error":
                                    data_return = "skip"
                                    # 返回阶段
                                    return data_return
                                else:
                                    # 【点击完成后】追加到element的id的记录列表中
                                    # 用于判断是否是重复项
                                    self.list_wechat_current_page_element_id.append(Record_Object_child_class_View_item)

                            # 自增
                            Record_Object_child_class_View_len_cursor = Record_Object_child_class_View_len_cursor + 1

                    else:

                        Record_Click_Object_str_patter = "/child::android.widget.LinearLayout[last()]" \
                                                         "/child::android.widget.LinearLayout[last()]"

                        Record_Click_Object = self.object_Appium.appium_find_element_by_xpath(
                            Start_Object=Record_Object,
                            enable_Start_Object_class=True,
                            one_or_more="more",
                            str_xpath=Record_Click_Object_str_patter
                        )

                        # 属性
                        Record_Click_Object_len = len(Record_Click_Object)

                        # 显示
                        # print("长度：" + str(Record_Click_Object_len))

                        # 测试：查看元素集合的内容
                        # self.object_Appium.appium_elements_display(
                        #     Start_Object=Record_Click_Object
                        # )

                        Record_Click_Object_len_cursor = 1
                        for Record_Click_Object_len_item in range(Record_Click_Object_len):

                            Record_Click_Object_in_for_loop = self.object_Appium.appium_find_element_by_xpath(
                                Start_Object=Record_Object,
                                enable_Start_Object_class=True,
                                one_or_more="more",
                                str_xpath=Record_Click_Object_str_patter
                            )

                            Record_Click_Object_item = self.object_Appium.appium_find_element_in_set_with_sequence_v2(
                                Object_Set=Record_Click_Object_in_for_loop,
                                which_one=Record_Click_Object_len_cursor
                            )
                            Record_Click_Object_item_resource_id = ""
                            Record_Click_Object_item_location_y = ""
                            Record_Click_Object_item_id = ""
                            if Record_Click_Object_item is not None:
                                # 属性
                                Record_Click_Object_item_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(
                                    Record_Click_Object_item
                                )
                                Record_Click_Object_item_location_y = Record_Click_Object_item.location.get('y')
                                Record_Click_Object_item_id = Record_Click_Object_item.id

                            # 判断：第一个【非空】的，就是我们要找的
                            if Record_Click_Object_item_resource_id != "<<Empty>>":

                                # print(" @@@@ 找到了【记录】点击对象 @@@@ ")
                                # print("Resource-Id / " + Record_Click_Object_item_resource_id)
                                # print("Location / y / " + str(Record_Click_Object_item_location_y))
                                # print("ID：【" + Record_Click_Object_item_id + "】")
                                # print("---- List / ID::Current")
                                # print(self.list_wechat_current_page_element_id)
                                # print("---- List / ID::Before")
                                # print(self.list_wechat_before_page_element_id)

                                # 当前找到的记录是否之前执行过点击
                                if Record_Click_Object_item_id in self.list_wechat_before_page_element_id:
                                    # print("---------> 当前记录【已经】查看过")
                                    data_return = "skip"
                                    # 返回阶段
                                    return data_return

                                # 【记录】动作流函数
                                result_status = self.wechat_moment_record_action_flow(
                                    Start_Object=Record_Click_Object_item
                                )

                                if result_status == "Error":
                                    data_return = "skip"
                                    # 返回阶段
                                    return data_return
                                else:
                                    # 【点击完成后】追加到element的id的记录列表中
                                    # 用于判断是否是重复项
                                    self.list_wechat_current_page_element_id.append(Record_Click_Object_item_id)

                                # 跳出循环，因为找到了目标记录
                                break

                            # 自增
                            Record_Click_Object_len_cursor = Record_Click_Object_len_cursor + 1

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # 返回阶段
        return data_return

    # 微信【朋友圈】--> 【单条记录】动作流
    def wechat_moment_record_action_flow(self, Start_Object):

        # 返回值
        data_return = True

        # 宣告
        # print(" @@@@ 【记录】动作流 @@@@")

        # 属性
        Start_Object_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(
            Start_Object
        )
        Start_Object_class = self.object_Appium.appium_element_get_attribute_CLASS(
            Start_Object
        )

        # 显示
        # print("-->> resource-id / " + Start_Object_resource_id)
        # print("-->> class / " + Start_Object_class)

        # 【图片或视频】或【纯文字】判断符
        words_or_media = ""

        # 判断
        if re.match("com.tencent.mm:id/f(.*)", Start_Object_resource_id):
            # print("当前记录为【图片或视频】")
            words_or_media = "media"
        else:
            # print("当前记录为【纯文字】")
            words_or_media = "words"

        if Start_Object_class == "android.view.View":
            words_or_media = "media"

        # ))))))))))))))))))))))))))))))
        # 进入 / 1
        # print("# 进入 / 1")
        Start_Object.click()

        # 等待
        self.object_Tool.time_do_wait(seconds_to_wait=2)

        # ))))))))))))))))))))))))))))))
        # 进入 / 2

        # 预定义值
        self.pinglun_total_number_object_text = 0

        if words_or_media == "media":
            # print("# 进入 / 2")

            # @@@@@@@@@@@@@@@@@@@@@ 第一次点击是否成功
            click_isOk = self.object_Appium.appium_isExsist_class_name(
                class_name="android.widget.ListView"
            )

            if click_isOk != "Error":
                # print(" #### 第一次点击【成功】 ####")
                pass
            else:
                # print(" #### 第一次点击【失败】 ####")

                data_return = "Error"

                # 返回阶段
                return data_return
            # @@@@@@@@@@@@@@@@@@@@@ 第一次点击是否成功

            click_2_page_object = self.object_Appium.appium_find_element_by_key_value(
                key="resource-id",
                value="android:id/content"
            )
            # 属性
            click_2_page_object_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(
                click_2_page_object
            )
            # 显示
            # print(click_2_page_object_resource_id)

            # 找到【第二次】的【点击元素】
            click_2_object_str_patter = "/child::android.widget.FrameLayout" \
                                        "/child::android.widget.FrameLayout" \
                                        "/child::android.widget.LinearLayout" \
                                        "/child::android.widget.LinearLayout" \
                                        "/child::android.widget.LinearLayout" \
                                        "/child::android.widget.FrameLayout" \
                                        "/child::android.widget.LinearLayout" \
                                        "/child::android.widget.LinearLayout" \
                                        "/child::android.widget.LinearLayout[last()]"
            click_2_object = None
            click_2_object_cursor = 0
            while click_2_object is None:
                click_2_object = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=click_2_page_object,
                    enable_Start_Object_class=True,
                    one_or_more="one",
                    str_xpath=click_2_object_str_patter
                )
                # 自增
                click_2_object_cursor = click_2_object_cursor + 1
                # 显示
                print("查找对象【click_2_object】 / 次数：" + str(click_2_object_cursor))

            # 查看到底有多少条【评论】
            pinglun_total_number_object_patter_string = "/child::android.widget.TextView[last()]"

            pinglun_total_number_object = self.object_Appium.appium_find_element_by_xpath(
                Start_Object=click_2_object,
                enable_Start_Object_class=True,
                one_or_more="one",
                str_xpath=pinglun_total_number_object_patter_string
            )

            self.pinglun_total_number_object_text = self.object_Appium.appium_element_get_attribute_TEXT(
                pinglun_total_number_object
            )

            if self.pinglun_total_number_object_text == "<<Empty>>":
                self.pinglun_total_number_object_text = 0

            print("@@@@@@@@@@@@@@---> 当前记录的【评论总数】 | " + str(self.pinglun_total_number_object_text))

            # 【执行点击】阶段
            if click_2_object is not None:
                click_2_object_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(
                    click_2_object
                )

                # print("【第二次·点击元素】resource-id：" + click_2_object_resource_id)

                # 执行：点击
                click_2_object.click()

        # @@@@@@@@@@@@@@@@@@@@@@@@@@
        # 到达【记录详情页】
        # print("# 到达【记录详情页】")

        # 详情页分析
        result = self.wechat_moment_record_detail_page_index()

        # @@@@@@@@@@@@@@@@@@@@@@@@@@

        # ))))))))))))))))))))))))))))))
        # 返回 / 1
        # print("# 返回 / 1")

        # 执行：返回
        self.object_Appium.appium_driver_object.keyevent(4)

        # ))))))))))))))))))))))))))))))
        # 返回 / 2
        if words_or_media == "media":
            # print("# 返回 / 2")

            # 执行：返回
            self.object_Appium.appium_driver_object.keyevent(4)

        # 返回阶段
        return data_return

    # 微信【朋友圈】--> 【单条记录】的【详情页】
    def wechat_moment_record_detail_page_index(self):

        # <editor-fold desc="函数级【变量声明】">

        # 返回值
        return_data = ""

        # 【While】循环 - 判定值
        self.top_while_condition = True

        # 第一次打开详情页的时候，是处于【头部】还是【尾部】
        first_screen_head_or_tail = ""

        # 找寻顶端
        enable_search_top = True

        # 找寻顶端的时候的滑动次数
        counts_while_search_top = 0

        # 找寻底部
        enable_search_bottom = False

        # 当前循环到了第几个评论
        self.pinglun_total_number_object_text_cursor = 0

        # 评论的记录列表
        self.list_pinglun_before_date = []
        self.list_pinglun_current_date = []

        # 是否完成：正文
        self.isDone_zhengwen = False

        # 是否存在：点赞
        isExsist_dianzan = False

        # 是否完成：点赞
        isDone_dianzan = False

        # 是否：评论
        is_pinglun = False

        # </editor-fold>

        # <editor-fold desc="函数级【While】顶级循环">
        while_condition_cursor = 1
        while self.top_while_condition:

            # 等待
            print("%%%")
            self.object_Tool.time_do_wait(seconds_to_wait=3)
            print("")

            # <editor-fold desc="函数级【While】顶级循环 / 头阶段">
            # 宣告
            # print("")
            # print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
            # print("))))))))))))))))))))))))))) 朋友圈【记录详情页】/ 函数级【While】顶级循环 / 当前批次【" + str(while_condition_cursor) + "】")
            # print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
            # print("")
            # </editor-fold>

            # <editor-fold desc="评论相关：重置队列">
            self.list_pinglun_current_date = []
            # </editor-fold>

            # <editor-fold desc="函数级【While】顶级循环 / 对象声明 / 第一次查找【ListView】">
            while_ListView = None
            while_ListView_cursor = 0
            while while_ListView is None:
                while_ListView = self.object_Appium.appium_find_element_by_key_value(
                    key="class",
                    value="android.widget.ListView"
                )
                # 自增
                while_ListView_cursor = while_ListView_cursor + 1
                # 宣告
                print("朋友圈【记录详情页】 / 当前屏幕 / 对象【ListView】 / 查找【" + str(while_ListView_cursor) + "】次")

            # </editor-fold>

            # <editor-fold desc="函数级【While】顶级循环 / 对象声明 /【ListView】/ 子集合">
            while_ListView_child_1_set = None
            while_ListView_child_1_set_cursor = 0
            while while_ListView_child_1_set is None:
                while_ListView_child_1_set = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=while_ListView,
                    enable_Start_Object_class=True,
                    one_or_more="more",
                    str_xpath="/child::android.widget.LinearLayout"
                )
                # 自增
                while_ListView_child_1_set_cursor = while_ListView_child_1_set_cursor + 1
                # 宣告
                print("朋友圈【记录详情页】 / 当前屏幕 / 对象【while_ListView_child_1_set】 / 查找【" + str(while_ListView_child_1_set_cursor) + "】次")

            while_ListView_child_1_set_len = len(while_ListView_child_1_set)

            # -- 属性 / 显示
            # print("朋友圈【记录详情页】/ ListView / 第一次查找 / 【一级】元素子集 / 长度：" + str(while_ListView_child_1_set_len))
            # </editor-fold>

            # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 ">
            while_ListView_child_1_set_len_cursor = 1
            for while_ListView_child_1_set_len_item in range(while_ListView_child_1_set_len):

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 前置【变量】与【对象】的获取">

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 头阶段">
                # 宣告
                print("")
                print("*************************************************")
                print(")))))))))))))---> 朋友圈【记录详情页】/ 顶级【ListView】/ 一级 / 子集合 / 循环 / 当前批次【" + str(
                    while_ListView_child_1_set_len_cursor) + "/" + str(while_ListView_child_1_set_len) + "】")
                print("")
                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 对象声明 / 第二次查找【ListView】">
                for_ListView = None

                for_ListView_cursor = 0
                while for_ListView is None:
                    # print(" !!!!!!!!! 元素对象【for_ListView】为空 !!!!!!!!!")
                    for_ListView = self.object_Appium.appium_find_element_by_key_value(
                        key="class",
                        value="android.widget.ListView"
                    )
                    # 自增
                    for_ListView_cursor = for_ListView_cursor + 1
                    # 显示
                    print("查找对象【for_ListView】 / 次数：" + str(for_ListView_cursor))

                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 当前循环的【起始对象】">
                Top_ListView_Child_item = None

                # New
                try:
                    Top_ListView_Child_item = self.object_Appium.appium_find_element_in_set_with_sequence(
                        Start_Object=for_ListView,
                        Class_Name="android.widget.LinearLayout",
                        which_one=while_ListView_child_1_set_len_cursor
                    )
                except Exception as excp:
                    pass

                # -- 属性
                Top_ListView_Child_item_resource_id = "<<Empty_init>>"
                if Top_ListView_Child_item is not None:
                    print("对象【Top_ListView_Child_item】非空")

                    Top_ListView_Child_item_resource_id_cursor = 1
                    while Top_ListView_Child_item_resource_id == "<<Empty_init>>":
                        Top_ListView_Child_item_resource_id = self.object_Appium.appium_element_get_attribute_RESOURCE_ID(
                            Top_ListView_Child_item
                        )
                        # 宣告
                        print("查找对象【Top_ListView_Child_item_resource_id】/ 次数：" + str(Top_ListView_Child_item_resource_id_cursor))

                        # 自增
                        Top_ListView_Child_item_resource_id_cursor = Top_ListView_Child_item_resource_id_cursor + 1

                else:
                    print("对象【Top_ListView_Child_item】为空")

                # -- 属性 / 显示
                print("@@@@ ListView / Child::LinearLayout / resource-id：" + Top_ListView_Child_item_resource_id)
                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 当前元素的属性 / 全部">
                Total_Object = None

                # New
                try:
                    Total_Object = self.object_Appium.appium_find_element_by_xpath(
                        Start_Object=Top_ListView_Child_item,
                        enable_Start_Object_class=True,
                        one_or_more="more",
                        str_xpath="/child::*"
                    )
                except Exception as excp:
                    pass

                # -- 属性
                Total_Object_len = 0
                if Total_Object is not None:
                    Total_Object_len = len(Total_Object)

                # -- 属性 / 显示
                print(" |----> 当前记录【元素对象】/ 子集 / 全部：数量：" + str(Total_Object_len))

                print("【isDone_zhengwen】" + str(self.isDone_zhengwen))
                print("【isExsist_dianzan】" + str(isExsist_dianzan))
                print("【isDone_dianzan】" + str(isDone_dianzan))
                print("【first_screen_head_or_tail】" + first_screen_head_or_tail)

                # 如果点赞完成了，如果正文完成了
                # 那么就是评论部分
                # 评论部分的【全部】子集数量小于7，则说明显示不全，可以跳过
                # 当前最后一个或者第一个
                # if while_ListView_child_1_set_len_cursor == while_ListView_child_1_set_len \
                #         or while_ListView_child_1_set_len_cursor == 1:
                #
                #     if Total_Object_len < 7 \
                #             and isDone_zhengwen \
                #             and isDone_dianzan \
                #             and Top_ListView_Child_item_resource_id != "<<Empty>>":
                #
                #         # 宣告
                #         print("当前【评论】元素【不完整】 ---> 【跳过】")
                #
                #         # 跳过 / 跳过的是【顶级ListView】的【for】循环
                #         continue

                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 当前元素的属性 / ImageView">
                ImageView_Object = None

                # New
                try:
                    ImageView_Object = self.object_Appium.appium_find_element_by_xpath(
                        Start_Object=Top_ListView_Child_item,
                        enable_Start_Object_class=True,
                        one_or_more="more",
                        str_xpath="/child::android.widget.ImageView"
                    )
                except Exception as excp:
                    pass

                # -- 属性
                ImageView_Object_len = 0
                if ImageView_Object is not None:
                    ImageView_Object_len = len(ImageView_Object)

                # -- 属性 / 显示
                print(" |----> 当前记录【元素对象】/ 子集 / ImageView：数量：" + str(ImageView_Object_len))
                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 当前元素的属性 / RelativeLayout">
                RelativeLayout_Object = None

                # New
                try:
                    RelativeLayout_Object = self.object_Appium.appium_find_element_by_xpath(
                        Start_Object=Top_ListView_Child_item,
                        enable_Start_Object_class=True,
                        one_or_more="more",
                        str_xpath="/child::android.widget.RelativeLayout"
                    )
                except Exception as excp:
                    pass

                # -- 属性
                RelativeLayout_Object_len = 0
                if RelativeLayout_Object is not None:
                    RelativeLayout_Object_len = len(RelativeLayout_Object)

                # -- 属性 / 显示
                print(" |----> 当前记录【元素对象】/ 子集 / RelativeLayout：数量：" + str(RelativeLayout_Object_len))
                # </editor-fold>

                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 判断阶段 / 第一次打开详情页 / 【头部】还是【尾部】？">
                if while_condition_cursor == 1:

                    if enable_search_top:
                        if not self.isDone_zhengwen:
                            print("!!!! -->>>> 【正文】部分还没有完成")
                            first_screen_head_or_tail = "tail"
                        else:
                            print("!!!! -->>>> 【正文】部分：完成")
                            first_screen_head_or_tail = "head"
                            # enable_search_top = False

                        if isExsist_dianzan:

                            if not isDone_dianzan:
                                print("!!!! -->>>> 【点赞】部分还没有完成")
                                first_screen_head_or_tail = "tail"
                            else:
                                print("!!!! -->>>> 【点赞】部分：完成")
                                first_screen_head_or_tail = "head"
                                # enable_search_top = False
                        else:
                            print("!!!! -->>>> 【点赞】部分：不存在")

                        if Total_Object_len > 7:

                            if while_ListView_child_1_set_len_cursor == 1:
                                first_screen_head_or_tail = "head"
                                # enable_search_top = False

                        else:
                            first_screen_head_or_tail = "tail"
                    else:
                        first_screen_head_or_tail = "head"

                print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
                print("@@@ 最终的结果：" + first_screen_head_or_tail)
                print("【enable_search_top】" + str(enable_search_top))

                # 显示 / 当前记录第一屏的【位置】属性
                # print("==========================")
                # print("当前记录【详情页】/ 第一屏 / 位置属性：" + first_screen_head_or_tail)
                # print("==========================")
                # </editor-fold>

                if first_screen_head_or_tail == "tail" and self.isDone_zhengwen:
                    first_screen_head_or_tail = "head"

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 找寻【详情页】最顶端 / Tail：才需要找寻【最顶端】">
                if first_screen_head_or_tail == "tail" and not self.isDone_zhengwen:
                    if enable_search_top:
                        if while_ListView_child_1_set_len_cursor == 1:

                            if not self.Record_isExsist_Date_Formate_String:

                                # 找到顶端
                                # 执行滑动
                                self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                                start_x=760, start_y=400,
                                                                end_x=760, end_y=1300)

                                # 重置循环条件
                                # -- 是否找寻顶端
                                enable_search_top = False

                                # -- 是否启用顶层【While】循环
                                self.top_while_condition = True

                                # 重置当前屏在【详情页】整体的位置
                                first_screen_head_or_tail = "head"

                                # 跳出当前【for】循环
                                # break

                            if Total_Object_len < 7 and self.Record_isExsist_Date_Formate_String:

                                # 宣告
                                # print("@@@@【滑动】@@@@ 找寻【详情页】/ 顶端")

                                # 执行滑动
                                self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                                start_x=760, start_y=400,
                                                                end_x=760, end_y=1300)

                                # 自增
                                counts_while_search_top = counts_while_search_top + 1

                                # 显示
                                # print(" |---> 找寻【详情页】/ 顶端 @ 当前【已滑动】次数：" + str(counts_while_search_top))

                                # 结束当前的【for】循环
                                # break

                        else:

                            # 宣告
                            # print("==========================")
                            # print("当前记录【详情页】/ 已经到达【顶端】")
                            # print("==========================")

                            # 到达顶端后，再执行一次滑动
                            self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                            start_x=760, start_y=400,
                                                            end_x=760, end_y=1300)

                            # 重置循环条件
                            # -- 是否找寻顶端
                            enable_search_top = False

                            # -- 是否启用顶层【While】循环
                            self.top_while_condition = True

                            # 重置当前屏在【详情页】整体的位置
                            first_screen_head_or_tail = "head"

                            # 跳出当前【for】循环
                            # break
                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 【详情页】 / 【正文】部分">
                if not self.isDone_zhengwen \
                    and Top_ListView_Child_item_resource_id == "<<Empty>>":
                    # and RelativeLayout_Object_len != 0:

                    print("【正文】部分 / " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

                    # 引用函数：正文
                    result = self.wechat_moment_record_detail_page_part_zhengwen(
                        Start_Object=Top_ListView_Child_item
                    )

                    print("")
                    print("********************************")
                    print("【初始】列表 / 长度：" + str(len(self.list_wechat_init_record_time_create)))
                    print(self.list_wechat_init_record_time_create)
                    print("********************************")
                    print("【之前】列表 / 长度：" + str(len(self.list_wechat_before_record_time_create)))
                    print(self.list_wechat_before_record_time_create)
                    print("********************************")
                    print("【现在】列表 / 长度：" + str(len(self.list_wechat_current_record_time_create)))
                    print(self.list_wechat_current_record_time_create)
                    print("")

                    if result == "skip":
                        print("当前记录【已经爬取过】---> @@ 跳过 @@")
                        return_data = "skip"
                        return return_data

                    # 重置部分
                    self.isDone_zhengwen = True
                    enable_search_top = False

                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 【详情页】 / 【点赞】部分">
                if not isDone_dianzan \
                        and self.isDone_zhengwen \
                        and Top_ListView_Child_item_resource_id == "<<Empty>>" \
                        and ImageView_Object_len != 0 \
                        and RelativeLayout_Object_len == 0:
                    print("【点赞】部分 / " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                    isDone_dianzan = True
                    isExsist_dianzan = True

                    # 引用函数：点赞
                    self.wechat_moment_record_detail_page_part_dianzan(
                        Start_Object=Top_ListView_Child_item
                    )
                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 【详情页】 / 【分隔符】部分">
                if Top_ListView_Child_item_resource_id == "<<Empty>>" \
                        and Total_Object_len == 0 \
                        and ImageView_Object_len == 0 \
                        and RelativeLayout_Object_len == 0:
                    print("【分隔符】部分 / " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 【详情页】 / 【评论】部分">
                if Top_ListView_Child_item_resource_id != "<<Empty>>":

                    begin_pinglun = False

                    if self.isDone_zhengwen:
                        begin_pinglun = True
                    else:
                        begin_pinglun = False

                    if isExsist_dianzan:
                        if isDone_dianzan:
                            begin_pinglun = True
                        else:
                            begin_pinglun = False

                    print("")
                    print("===============================")
                    print("【评论】部分 / " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                    is_pinglun = True

                    # 判断评论内容是否完整
                    if RelativeLayout_Object_len == 0:
                        print(" |----> !!!! @ 当前评论内容【不完整】 @ !!!!")

                        # 跳过
                        # continue

                    else:
                        if begin_pinglun:
                            self.wechat_moment_record_detail_page_part_pinglun(Start_Object=Top_ListView_Child_item)

                    # 输出当前的评论位置
                    if first_screen_head_or_tail == "head":
                        print("@@@@@@@@@@@@@@@@@@@@@@")
                        print("当前评论位于：【" + str(self.pinglun_total_number_object_text_cursor) + "/" + str(
                            self.pinglun_total_number_object_text) + "】")
                        print("@@@@@@@@@@@@@@@@@@@@@@")
                        print("")

                        # 重置评论部分
                        self.Record_isExsist_Date_Formate_String = False

                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 找寻【详情页】最底端 / Head：才需要找寻【最底端】">
                if first_screen_head_or_tail == "head":

                    # 如果已经到达【当前屏幕】的【最后一项】
                    if while_ListView_child_1_set_len_cursor == while_ListView_child_1_set_len:

                        print("%%%%%%%%%%%%%%%%%%% 当前屏幕【最后一项】")

                        if while_ListView_child_1_set_len == 1:

                            reset_while = False

                            if not self.isDone_zhengwen:
                                reset_while = True

                            if isExsist_dianzan and not isDone_dianzan:
                                reset_while = True

                            if reset_while:
                                # 重置顶级【while】循环条件
                                self.top_while_condition = True
                                continue

                        # 只有【图片或者视频】的记录才可以拿到【self.pinglun_total_number_object_text】
                        if self.pinglun_total_number_object_text != 0:

                            # 图片或视频记录
                            # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
                            # print("图片或视频记录")
                            # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")

                            if self.pinglun_total_number_object_text_cursor < int(
                                    self.pinglun_total_number_object_text):

                                if self.list_pinglun_before_date == self.list_pinglun_current_date and is_pinglun:

                                    # 重置顶级【while】循环条件
                                    self.top_while_condition = False

                                    # 跳出群欢
                                    continue

                                if self.pinglun_total_number_object_text_cursor == 0 and is_pinglun:

                                    # 重置顶级【while】循环条件
                                    self.top_while_condition = True

                                    # 跳出群欢
                                    continue

                                # 当前评论【不是】最后一条评论
                                # print(" |--------> 【当前评论】不是【最后】一条【评论】")
                                # print("@@@@@@@@@@@@@@@@@@@@@@")
                                # print(
                                #     "当前评论位于：【" + str(self.pinglun_total_number_object_text_cursor) + "/" + str(
                                #         self.pinglun_total_number_object_text) + "】")
                                # print("@@@@@@@@@@@@@@@@@@@@@@")
                                # print("之前：")
                                # print("-------------------------")
                                # print(self.list_pinglun_before_date)
                                # print("-------------------------")
                                # print("现在：")
                                # print("-------------------------")
                                # print(self.list_pinglun_current_date)
                                # print("-------------------------")

                                # 执行滑动：上翻
                                self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                                start_x=760, start_y=1300,
                                                                end_x=760, end_y=400)

                                # 重置条件
                                self.list_pinglun_before_date = self.list_pinglun_current_date

                                # 重置顶级【while】循环条件
                                self.top_while_condition = True

                                # 跳出群欢
                                continue

                            else:
                                # 当前评论【是】最后一条评论
                                # print(" |--------> 【当前评论】就是【最后】一条【评论】")
                                # print("@@@@@@@@@@@@@@@@@@@@@@")
                                # print(
                                #     "当前评论位于：【" + str(self.pinglun_total_number_object_text_cursor) + "/" + str(
                                #         self.pinglun_total_number_object_text) + "】")
                                # print("@@@@@@@@@@@@@@@@@@@@@@")
                                # print("之前：")
                                # print("-------------------------")
                                # print(self.list_pinglun_before_date)
                                # print("-------------------------")
                                # print("现在：")
                                # print("-------------------------")
                                # print(self.list_pinglun_current_date)
                                # print("-------------------------")

                                # 重置条件
                                self.list_pinglun_before_date = self.list_pinglun_current_date

                                # 重置顶级【while】循环条件
                                self.top_while_condition = False

                                # 跳出群欢
                                continue

                        else:

                            # 文字的记录

                            # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
                            # print("文字记录")
                            # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")

                            if self.list_pinglun_before_date == self.list_pinglun_current_date:

                                # 如果当前画面的列表和前一个一样，则说明到达了【评论】的最后一页
                                # print(" |--------> 【当前评论】就是【最后】一条【评论】")
                                # print("之前：")
                                # print("-------------------------")
                                # print(self.list_pinglun_before_date)
                                # print("-------------------------")
                                # print("现在：")
                                # print("-------------------------")
                                # print(self.list_pinglun_current_date)
                                # print("-------------------------")

                                # 重置顶级【while】循环条件
                                self.top_while_condition = False

                                # 跳出群欢
                                continue

                            else:
                                # 当前评论【不是】最后一条评论
                                # print(" |--------> 【当前评论】不是【最后】一条【评论】")
                                # print("之前：")
                                # print("-------------------------")
                                # print(self.list_pinglun_before_date)
                                # print("-------------------------")
                                # print("现在：")
                                # print("-------------------------")
                                # print(self.list_pinglun_current_date)
                                # print("-------------------------")

                                # 执行滑动：上翻
                                self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                                start_x=760, start_y=1300,
                                                                end_x=760, end_y=400)

                                # 重置条件
                                self.list_pinglun_before_date = self.list_pinglun_current_date

                                # 重置顶级【while】循环条件
                                self.top_while_condition = True

                                # 跳出群欢
                                continue

                # </editor-fold>

                # <editor-fold desc="函数级【While】顶级循环 / 顶级【ListView】子集 / 循环 / 结束阶段">
                # 自增
                while_ListView_child_1_set_len_cursor = while_ListView_child_1_set_len_cursor + 1
                # </editor-fold>

            # </editor-fold>

            # <editor-fold desc="函数级【While】顶级循环 / 结束阶段">
            # 自增
            while_condition_cursor = while_condition_cursor + 1
            # </editor-fold>

        # </editor-fold>

        # <editor-fold desc="函数级【结束阶段】">

        # 返回阶段
        return return_data

        # </editor-fold>

    # 微信【朋友圈】--> 【单条记录】的【详情页】 / 正文部分
    def wechat_moment_record_detail_page_part_zhengwen(self, Start_Object):

        # print("")
        # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
        # print("分析【正文部分】")
        # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
        # print("")

        # 返回值
        return_data = "Done"

        # -- 变量 / 文字部分
        list_data_words = []

        # 是否有时间格式的文本
        self.Record_isExsist_Date_Formate_String = False

        # 是否找到记录的作者名字部分？
        is_Found_NickName = False

        # While循环 - 判定值
        while_condition_in_def = True

        # 包含图片还是视频
        is_Content_Pic_or_Video = ""

        # while，循环
        # -- 解决正文过长，超过一屏幕的问题
        while while_condition_in_def:

            # 等待
            self.object_Tool.time_do_wait(seconds_to_wait=3)

            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 正文 / 文字部分

            # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 找到昵称
            if not is_Found_NickName:
                # print("")
                # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
                # print("是否位于【正文：头部 / 昵称部分】")
                # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
                # print("")

                print("")
                print("===========================================")
                print("@@@@@@@@@@@@@@@@@@@@ WHILE 1 / 【查找：昵称】阶段")
                print("是否找到昵称：" + str(is_Found_NickName))
                print("是否找到日期：" + str(self.Record_isExsist_Date_Formate_String))
                print("")

                Nick_Name_Object_text = "<<Empty_init>>"

                try:
                    ListView_in_def = self.object_Appium.appium_find_element_by_key_value(
                        key="class", value="android.widget.ListView"
                    )
                    zhengwen_Object = self.object_Appium.appium_find_element_in_set_with_sequence(
                        Start_Object=ListView_in_def,
                        Class_Name="android.widget.LinearLayout",
                        which_one=1
                    )
                    zhengwen_Object_TextView_set = None
                    if zhengwen_Object is not None:
                        zhengwen_Object_TextView_set = zhengwen_Object.find_elements_by_class_name("android.widget.TextView")

                    list_zhengwen_Object_TextView_set = []
                    for zhengwen_Object_TextView_set_item in zhengwen_Object_TextView_set:
                        zhengwen_Object_TextView_set_item_text = self.object_Appium.appium_element_get_attribute_TEXT(zhengwen_Object_TextView_set_item)

                        if zhengwen_Object_TextView_set_item_text not in list_zhengwen_Object_TextView_set:
                            list_zhengwen_Object_TextView_set.append(zhengwen_Object_TextView_set_item_text)

                    print("列表【list_zhengwen_Object_TextView_set】 / " + str(list_zhengwen_Object_TextView_set))

                    # 赋值
                    Nick_Name_Object_text = list_zhengwen_Object_TextView_set[0]

                except Exception as excp:
                    pass

                # @@@@@@@@@@@@@@@@@@@@@@@@@
                # 判断

                print("【昵称元素】位置 / 当前值：" + Nick_Name_Object_text)

                if Nick_Name_Object_text == self.info_wechat_nick_name:

                    is_Found_NickName = True

                    while_condition_in_def = False

                else:
                    while_condition_in_def = True

                    print("因为找不到【昵称】，从而【滑动】")

                    # 滑动：
                    self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                    start_x=760, start_y=600,
                                                    end_x=760, end_y=1300)

                    # 等待
                    self.object_Tool.time_do_wait(seconds_to_wait=2)

            # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 分析文字部分

            # New

            try:
                ListView_in_def = self.object_Appium.appium_find_element_by_key_value(
                    key="class", value="android.widget.ListView"
                )
                zhengwen_Object = self.object_Appium.appium_find_element_in_set_with_sequence(
                    Start_Object=ListView_in_def,
                    Class_Name="android.widget.LinearLayout",
                    which_one=1
                )
                zhengwen_Object_TextView_set = None
                if zhengwen_Object is not None:
                    zhengwen_Object_TextView_set = zhengwen_Object.find_elements_by_class_name("android.widget.TextView")

                for zhengwen_Object_TextView_set_item in zhengwen_Object_TextView_set:
                    zhengwen_Object_TextView_set_item_text = self.object_Appium.appium_element_get_attribute_TEXT(
                        zhengwen_Object_TextView_set_item)

                    if zhengwen_Object_TextView_set_item_text not in list_data_words \
                            and zhengwen_Object_TextView_set_item_text not in ['删除', '<<Empty>>']:
                        list_data_words.append(zhengwen_Object_TextView_set_item_text)

                print("列表【list_data_words】 / " + str(list_data_words))

            except Exception as excp:
                pass

            # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 找到日期
            if is_Found_NickName \
                    and not self.Record_isExsist_Date_Formate_String:

                # print("")
                # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
                # print("是否位于【正文：尾部 / 发布日期部分】")
                # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
                # print("")

                print("")
                print("===========================================")
                print("@@@@@@@@@@@@@@@@@@@@ WHILE 2 / 【查找：日期】阶段")
                print("是否找到昵称：" + str(is_Found_NickName))
                print("是否找到日期：" + str(self.Record_isExsist_Date_Formate_String))
                print("")

                Date_String_Object_text = "<<Empty>>"

                try:
                    ListView_in_def = self.object_Appium.appium_find_element_by_key_value(
                        key="class", value="android.widget.ListView"
                    )
                    zhengwen_Object = self.object_Appium.appium_find_element_in_set_with_sequence(
                        Start_Object=ListView_in_def,
                        Class_Name="android.widget.LinearLayout",
                        which_one=1
                    )
                    zhengwen_Object_TextView_set = None
                    if zhengwen_Object is not None:
                        zhengwen_Object_TextView_set = zhengwen_Object.find_elements_by_class_name(
                            "android.widget.TextView")

                    list_zhengwen_Object_TextView_set = []
                    for zhengwen_Object_TextView_set_item in zhengwen_Object_TextView_set:
                        zhengwen_Object_TextView_set_item_text = self.object_Appium.appium_element_get_attribute_TEXT(
                            zhengwen_Object_TextView_set_item)

                        if re.match("[0-9]{4}年[0-9]{1,2}月[0-9]{1,2}日 [0-9]{1,2}:[0-9]{1,2}$", zhengwen_Object_TextView_set_item_text) \
                                or re.match("昨天 [0-9]{1,2}:[0-9]{1,2}$", zhengwen_Object_TextView_set_item_text) \
                                or re.match("[0-9]{1,2}:[0-9]{1,2}$", zhengwen_Object_TextView_set_item_text):

                            Date_String_Object_text = zhengwen_Object_TextView_set_item_text

                            self.Record_isExsist_Date_Formate_String = True

                            while_condition_in_def = False

                except Exception as excp:
                    pass

                print("【时间元素】位置 / 当前值：" + Date_String_Object_text)
                print("是否找到：" + str(self.Record_isExsist_Date_Formate_String))

                if not self.Record_isExsist_Date_Formate_String:
                    while_condition_in_def = True

                    # 滑动：
                    self.object_Appium.appium_swipe(swipe_count=1, swipe_duration=500,
                                                    start_x=760, start_y=1300,
                                                    end_x=760, end_y=600)

                if self.Record_isExsist_Date_Formate_String:
                    while_condition_in_def = False
                    self.isDone_zhengwen = True
                    self.top_while_condition = True

            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 显示最后的值：
        print("文字部分：" + str(list_data_words))
        print("")

        # 今天的日期
        # date_string_today = (date.today()).strftime("%Y年%m月%d日").encode('utf-8')
        # date_string_today = datetime.date.today().strftime("%Y年%m月%d日")
        date_string_today = datetime.date.today().strftime('%Y{y}%m{m}%d{d}').format(y='年',m='月',d='日')

        # 昨天的日期
        # date_string_yesterday = (date.today() + timedelta(days = -1)).strftime("%Y年%m月%d日")
        date_string_yesterday = (date.today() + timedelta(days=-1)).strftime('%Y{y}%m{m}%d{d}').format(y='年',m='月',d='日')

        # 发布时间 - 列表的最后一项
        target_date_string = list_data_words[-1]

        if ":" not in target_date_string:
            target_date_string = list_data_words[-2]

        if len(list_data_words) != 0:
            self.wechat_record_time_create = target_date_string.replace(":","-").replace("昨天",date_string_yesterday)

        if " " not in self.wechat_record_time_create:
            self.wechat_record_time_create = date_string_today + " " + self.wechat_record_time_create

        if ":" not in list_data_words[-1]:
            list_data_words[-2] = self.wechat_record_time_create

        if ":" in list_data_words[-1]:
            list_data_words[-1] = self.wechat_record_time_create

        self.wechat_record_time_create = self.wechat_record_time_create.replace(" ","_")

        # 追加列表
        self.list_wechat_current_record_time_create.append(self.wechat_record_time_create)

        # 判断是否之前执行过？
        if self.wechat_record_time_create in self.list_wechat_init_record_time_create:
            return_data = "skip"
            return return_data

        if self.wechat_record_time_create in self.list_wechat_before_record_time_create:
            return_data = "skip"
            return return_data

        # 创建对应目录
        if not self.path_wechat_pc_root.endswith('/'):
            self.path_wechat_pc_root = self.path_wechat_pc_root + "/"

        self.path_wechat_pc_finally = str(self.path_wechat_pc_root + self.wechat_record_time_create).replace(" ","_")

        # 显示
        print("存放到PC的【最终路径】：" + self.path_wechat_pc_finally)

        # 创建
        self.object_Tool.do_path(string_path=self.path_wechat_pc_finally)

        # 文本内容 / 写入路径
        self.path_wechat_pc_finally_file = self.path_wechat_pc_finally + "/content.txt"

        # 文字内容：执行写入
        data_words = ""

        for list_data_words_item in list_data_words:
            data_words = data_words + list_data_words_item + "\n=======================\n"

        self.object_Tool.do_file(
            file_path=self.path_wechat_pc_finally_file,
            write_data=data_words,
            write_type='w'
        )
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # -- 变量 / 【图片】部分
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 【图片】部分
        Part_Pic = None
        Part_Pic_cursor = 0
        while Part_Pic is None and Part_Pic_cursor < 3:
            try:
                Part_Pic = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=Start_Object,
                    enable_Start_Object_class=True,
                    one_or_more="more",
                    str_xpath="/child::android.widget.RelativeLayout"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.FrameLayout"
                              "/child::android.view.View"
                )
            except Exception as excp:
                pass

            # 自增
            Part_Pic_cursor = Part_Pic_cursor + 1

        Part_Pic_len = ""
        if Part_Pic is not None:
            Part_Pic_len = len(Part_Pic)

        # Part_Pic = Start_Object.find_elements_by_class_name("android.view.View")

        # Part_Pic = self.object_Appium.appium_find_element_by_key_value(
        #     key="content-desc",
        #     value="图片",
        #     Start_Object=Start_Object
        # )

        Part_Pic_len = 0

        if Part_Pic is not None:
            is_Content_Pic_or_Video = "pic"

            Part_Pic_len = len(Part_Pic)
            print("【多媒体】内容为：@@@@ 图片 @@@@ / 长度：" + str(Part_Pic_len))

            # 循环
            Part_Pic_cursor = 1
            for Part_Pic_len_item in range(Part_Pic_len):

                Part_Pic_in_for_loop = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=Start_Object,
                    enable_Start_Object_class=True,
                    one_or_more="more",
                    str_xpath="/child::android.widget.RelativeLayout"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.FrameLayout"
                              "/child::android.view.View"
                )

                Part_Pic_item = self.object_Appium.appium_find_element_in_set_with_sequence_v2(
                    Object_Set=Part_Pic_in_for_loop,
                    which_one=Part_Pic_cursor
                )

                # 宣告
                print("当前【" + str(Part_Pic_cursor) + "】图片")

                if self.wechat_record_time_create not in self.list_wechat_before_record_time_create:
                    # 保存 动作流
                    if Part_Pic_len != 0:
                        self.wechat_pic_or_video_action_flow(Start_Object=Part_Pic_item, click_type="图片")

                    # 找到文件
                    file_in_Phone = self.object_Android_ADB.adb_file_find(
                        path=self.path_wechat_phone,
                        head_or_tail="tail",
                        counts=1)

                    # --- 显示
                    print("文件地址（手机）：" + str(file_in_Phone))

                    # 将存放到手机的文件，传输到PC
                    self.object_Android_ADB.adb_do_pull(source_list=file_in_Phone,pc_path=self.path_wechat_pc_finally)

                # 自增
                Part_Pic_cursor = Part_Pic_cursor +1
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # -- 变量 / 【视频】部分
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 【视频】部分
        Part_Video = None
        Part_Video_cursor = 0
        while Part_Video is None and Part_Video_cursor < 3:
            try:
                Part_Video = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=Start_Object,
                    enable_Start_Object_class=True,
                    one_or_more="more",
                    str_xpath="/child::android.widget.RelativeLayout"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.LinearLayout[last()]"
                              "/child::android.widget.LinearLayout"
                              "/child::android.widget.FrameLayout"
                              "/child::android.widget.RelativeLayout"
                )
            except Exception as excp:
                pass

            # 自增
            Part_Video_cursor = Part_Video_cursor + 1

        # Part_Video = Start_Object.find_elements_by_class_name("android.widget.RelativeLayout")

        Part_Video_len = 0

        if Part_Video is not None:
            is_Content_Pic_or_Video = "video"

            Part_Video_len = len(Part_Video)
            print("【多媒体】内容为：@@@@ 视频 @@@@ / 长度：" + str(Part_Video_len))

            # 循环
            Part_Video_cursor = 1
            for Part_Video_item in Part_Video:

                # 宣告
                print("当前【" + str(Part_Video_cursor) + "】视频")

                if self.wechat_record_time_create not in self.list_wechat_before_record_time_create:
                    # 保存 动作流
                    if Part_Video_len != 0:
                        self.wechat_pic_or_video_action_flow(Start_Object=Part_Video_item, click_type="视频")

                    # 找到文件
                    file_in_Phone = self.object_Android_ADB.adb_file_find(
                        path=self.path_wechat_phone,
                        head_or_tail="tail",
                        counts=1)

                    # --- 显示
                    print("文件地址（手机）：" + str(file_in_Phone))

                    # 将存放到手机的文件，传输到PC
                    self.object_Android_ADB.adb_do_pull(source_list=file_in_Phone, pc_path=self.path_wechat_pc_finally)

                # 自增
                Part_Video_cursor = Part_Video_cursor + 1

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 返回阶段
        return return_data

    # 微信【朋友圈】--> 【单条记录】的【详情页】 / 点赞部分
    def wechat_moment_record_detail_page_part_dianzan(self, Start_Object):
        # print("")
        # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
        # print("分析【点赞部分】")
        # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
        # print("")

        # 最终写入数据
        self.dianzan_write_data = ""

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        User_Image = self.object_Appium.appium_find_element_by_xpath(
            Start_Object=Start_Object,
            enable_Start_Object_class=True,
            one_or_more="more",
            str_xpath="/child::android.widget.LinearLayout"
                      "/child::android.widget.LinearLayout"
                      "/child::android.widget.ImageView"
        )
        User_Image_len = len(User_Image)
        self.dianzan_write_data = "点赞人数【" + str(User_Image_len) + "】"

        # 显示
        print(self.dianzan_write_data)
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 写入文件
        self.object_Tool.do_file(
            file_path=self.path_wechat_pc_finally_file,
            write_data=self.dianzan_write_data,
            write_type='a'
        )

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        User_Image_Lines = self.object_Appium.appium_find_element_by_xpath(
            Start_Object=Start_Object,
            enable_Start_Object_class=True,
            one_or_more="more",
            str_xpath="/child::android.widget.LinearLayout"
                      "/child::android.widget.LinearLayout"
        )
        User_Image_Lines_len = len(User_Image_Lines)

        print("【点赞】部分 / 行数：" + str(User_Image_Lines_len))

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

        User_Image_Lines_len_cursor = 1
        for User_Image_Lines_len_item in range(User_Image_Lines_len):

            print("【点赞】部分 / 行 / 当前行：" + str(User_Image_Lines_len_cursor))

            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
            User_Image_Lines_in_for_loop = self.object_Appium.appium_find_element_by_xpath(
                Start_Object=Start_Object,
                enable_Start_Object_class=True,
                one_or_more="more",
                str_xpath="/child::android.widget.LinearLayout"
                          "/child::android.widget.LinearLayout"
            )

            User_Image_Lines_in_for_loop_item = self.object_Appium.appium_find_element_in_set_with_sequence_v2(
                Object_Set=User_Image_Lines_in_for_loop,
                which_one=User_Image_Lines_len_cursor
            )
            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
            User_Image_Lines_in_for_loop_item_child_ImageView_Set = self.object_Appium.appium_find_element_by_xpath(
                Start_Object=User_Image_Lines_in_for_loop_item,
                enable_Start_Object_class=True,
                one_or_more="more",
                str_xpath="/child::android.widget.ImageView"
            )
            User_Image_Lines_in_for_loop_item_child_ImageView_Set_len = len(User_Image_Lines_in_for_loop_item_child_ImageView_Set)

            print("【点赞】部分 / 行 / 当前行：" + str(User_Image_Lines_len_cursor) + " / ImageView / 个数：" +
                  str(User_Image_Lines_in_for_loop_item_child_ImageView_Set_len))
            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

            User_Image_Lines_in_for_loop_item_child_ImageView_Set_len_cursor = 1
            for User_Image_Lines_in_for_loop_item_child_ImageView_Set_len_item in range(User_Image_Lines_in_for_loop_item_child_ImageView_Set_len):

                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                print("")
                print("【点赞】部分 / 行 / 当前行：" + str(User_Image_Lines_len_cursor) + " / ImageView / 第几个："
                      + str(User_Image_Lines_in_for_loop_item_child_ImageView_Set_len_cursor))
                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

                Before_DianZan_Check_Is_Top = None
                Before_DianZan_Check_Is_Top_cursor = 1
                while Before_DianZan_Check_Is_Top is None:
                    Before_DianZan_Check_Is_Top = self.object_Appium.appium_find_element_by_key_value(
                        key="class",
                        value="android.widget.ListView"
                    )
                    print("查找对象【Before_DianZan_Check_Is_Top】次数：" + str(
                        Before_DianZan_Check_Is_Top_cursor))
                    Before_DianZan_Check_Is_Top_cursor = Before_DianZan_Check_Is_Top_cursor + 1

                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                # Before_DianZan_Check_Is_Top_Item_first = self.object_Appium.appium_find_element_by_xpath(
                #     Start_Object=Before_DianZan_Check_Is_Top,
                #     enable_Start_Object_class=True,
                #     str_xpath="/child::android.widget.LinearLayout[1]/child::*",
                #     one_or_more="more"
                # )
                # Before_DianZan_Check_Is_Top_Item_first = None
                # Before_DianZan_Check_Is_Top_Item_first_cursor = 1
                # while Before_DianZan_Check_Is_Top_Item_first is None:
                #     Before_DianZan_Check_Is_Top_Item_first = self.object_Appium.appium_find_element_by_xpath(
                #         Start_Object=Before_DianZan_Check_Is_Top,
                #         enable_Start_Object_class=True,
                #         str_xpath="/child::android.widget.LinearLayout[1]/*",
                #         one_or_more="more"
                #     )
                #     print("查找对象【Before_DianZan_Check_Is_Top_Item_first】次数：" + str(Before_DianZan_Check_Is_Top_Item_first_cursor))
                #     Before_DianZan_Check_Is_Top_Item_first_cursor = Before_DianZan_Check_Is_Top_Item_first_cursor + 1
                #
                # Before_DianZan_Check_Is_Top_Item_first_len = len(Before_DianZan_Check_Is_Top_Item_first)
                # print("当前【屏幕】 / ListView / 第一个【一级子对象】 / 子集长度：" + str(Before_DianZan_Check_Is_Top_Item_first_len))
                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                User_Image_Lines_in_for_loop_item_child_ImageView_Set_in_for_loop = self.object_Appium.appium_find_element_by_xpath(
                    Start_Object=User_Image_Lines_in_for_loop_item,
                    enable_Start_Object_class=True,
                    one_or_more="more",
                    str_xpath="/child::android.widget.ImageView"
                )
                User_Image_Lines_in_for_loop_item_child_ImageView_Set_in_for_loop_item = self.object_Appium.appium_find_element_in_set_with_sequence_v2(
                    Object_Set=User_Image_Lines_in_for_loop_item_child_ImageView_Set_in_for_loop,
                    which_one=User_Image_Lines_in_for_loop_item_child_ImageView_Set_len_cursor
                )
                # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

                # ===========================
                # 等待
                # self.object_Tool.time_do_wait(seconds_to_wait=2)

                # 执行
                User_Image_Lines_in_for_loop_item_child_ImageView_Set_in_for_loop_item.click()

                # 动作流
                self.wechat_dianzan_user_head_image_action_flow(Start_Object=User_Image_Lines_in_for_loop_item_child_ImageView_Set_in_for_loop_item)
                # ===========================

                # 自增
                User_Image_Lines_in_for_loop_item_child_ImageView_Set_len_cursor = User_Image_Lines_in_for_loop_item_child_ImageView_Set_len_cursor + 1

            # 自增
            User_Image_Lines_len_cursor = User_Image_Lines_len_cursor + 1

    # 微信【朋友圈】--> 【单条记录】的【详情页】 / 评论部分
    def wechat_moment_record_detail_page_part_pinglun(self, Start_Object):

        if Start_Object is None:
            print("评论分析部分【Start_Object】为空")

        # print("")
        # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
        # print("分析【评论部分】")
        # print("%%%%%%%%%%%%%%%%%%%%%%%%%")
        # print("")

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # -- 变量 / 文字部分
        list_data_words = []
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 【文字部分】
        # Part_Words = self.object_Appium.appium_find_element_by_xpath(
        #     Start_Object=Start_Object,
        #     enable_Start_Object_class=True,
        #     one_or_more="more",
        #     str_xpath="/child::android.widget.TextView"
        # )
        Part_Words = None

        try:
            Part_Words = Start_Object.find_elements_by_class_name("android.widget.TextView")
        except Exception as excp:
            pass

        if Part_Words is None:
            return "None Error"

        if Part_Words is not None:
            # 测试
            # self.object_Appium.appium_elements_display(
            #     Start_Object=Part_Words
            # )

            for Part_Words_item in Part_Words:

                # 属性
                Part_Words_item_text = self.object_Appium.appium_element_get_attribute_TEXT(
                    Part_Words_item
                )

                if Part_Words_item_text not in ['删除', '<<Empty>>', '<<Empty_Text | INIT>>']:
                    list_data_words.append(Part_Words_item_text)

        # 加入判定列表的字段
        current_status = ""
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # --- 评论内容时间处理

        # print("评论内容 / 格式化时间【前】：" + str(list_data_words))

        # 今天的日期
        date_string_today = datetime.date.today().strftime('%Y{y}%m{m}%d{d}').format(y='年', m='月', d='日')

        # 昨天的日期
        date_string_yesterday = (date.today() + timedelta(days=-1)).strftime('%Y{y}%m{m}%d{d}').format(y='年',
                                                                                                    m='月',
                                                                                                    d='日')

        # 发布时间 - 列表的最后一项
        if len(list_data_words) != 0:

            if len(list_data_words) >= 2:
                list_data_words[-2] = list_data_words[-2].replace(":", "-").replace("昨天", date_string_yesterday)

                if " " not in list_data_words[-2]:
                    list_data_words[-2] = date_string_today + " " + list_data_words[-2]

                # 追加到时间列表
                current_status = list_data_words[-2] + " || " + list_data_words[-1]

        if current_status not in self.list_pinglun_current_date:
            self.list_pinglun_current_date.append(current_status)

        # 显示最后的值：
        print("评论内容 / 格式化时间【后】：" + str(list_data_words))

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        print("**************************************")
        print("当前状态【" + current_status + "】")
        print("当前列表 / 长度：" + str(len(self.list_pinglun_current_date)))
        print("----------------------")
        print(self.list_pinglun_current_date)
        print("之前列表 / 长度：" + str(len(self.list_pinglun_before_date)))
        print("----------------------")
        print(self.list_pinglun_before_date)

        if current_status not in self.list_pinglun_before_date:

            print("@@@@--->>> 当前评论没有记录过")

            # 评论游标自增
            self.pinglun_total_number_object_text_cursor = self.pinglun_total_number_object_text_cursor + 1

            # @@@@@@@@@@@@@@@@@@@@@@@@@@@@
            # 写入数据
            write_data = ""

            for list_data_words_item in list_data_words:
                write_data = write_data + list_data_words_item + "\n----------------\n"

            write_data = "\n########---->> | " + write_data

            # 显示
            # print("@@@@@@@@@ 最终写入数据为：")
            # print("------------------------------")
            # print(write_data)
            # print("------------------------------")

            # 写入文件
            self.object_Tool.do_file(
                file_path=self.path_wechat_pc_finally_file,
                write_data=write_data,
                write_type='a'
            )

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    # 微信【朋友圈】--> 头部分析
    def wechat_moment_part_head(self, Start_Object):

        # 变量
        file_Author = ""
        if not self.path_wechat_pc_root.endswith("/"):
            file_Author = self.path_wechat_pc_root + "/" + "About_Author.txt"

        # 如果不存在就创建一个空文件
        if file_Author != "":
            if not os.path.exists(file_Author):
                file_Obj = open(file_Author,'w')
                file_Obj.close()

        # print("第一阶段")
        # file_data = self.object_Tool.read_file(file_path=file_Author, read_type="r")
        # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@")
        # print(file_data)
        # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@")

        file_data = self.object_Tool.read_file(file_path=file_Author, read_type="r")

        # 第一次写文件
        data_to_write = ")))))))))))))))))))))))))))\n" \
                        "当前微信朋友圈【作者信息】\n" \
                        ")))))))))))))))))))))))))))\n"

        if file_data != []:
            if len(file_data) >= 2:
                if "当前微信朋友圈【作者信息】" not in file_data[1]:
                    # 第一次写文件
                    self.object_Tool.do_file(file_path=file_Author,write_data=data_to_write,write_type="a+")
        else:
            self.object_Tool.do_file(file_path=file_Author, write_data=data_to_write, write_type="a+")

        # print("第二阶段")
        # file_data = self.object_Tool.read_file(file_path=file_Author, read_type="r")
        # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@")
        # print(file_data)
        # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@")

        print("")
        print("@@@@@@@@@@@@@@@@@")
        print("分析：朋友圈【头部】")
        print("@@@@@@@@@@@@@@@@@")
        print("")

        if Start_Object is not None:
            print("【朋友圈】头部 / 起始对象【Start_Object】- 不为空")

        # Old
        # Start_Object_child_TextView = self.object_Appium.appium_find_element_by_xpath(
        #     Start_Object=Start_Object,
        #     enable_Start_Object_class=True,
        #     one_or_more="more",
        #     str_xpath="/child::android.widget.RelativeLayout"
        #               "/child::android.widget.TextView"
        # )

        # New
        Start_Object_child_TextView = Start_Object.find_elements_by_class_name("android.widget.TextView")

        Start_Object_child_TextView_len = len(Start_Object_child_TextView)

        # 显示
        print("【头部】TextView / 个数：" + str(Start_Object_child_TextView_len))
        print("")

        # 生成数据
        list_author_info = []

        # 循环写入
        for Start_Object_child_TextView_item in Start_Object_child_TextView:
            # 属性
            Start_Object_child_TextView_item_text = self.object_Appium.appium_element_get_attribute_TEXT(Start_Object_child_TextView_item)

            # 写入
            if Start_Object_child_TextView_item_text not in list_author_info:
                list_author_info.append(Start_Object_child_TextView_item_text)

        # 显示
        print("原始数据：" + str(list_author_info))

        file_data = self.object_Tool.read_file(file_path=file_Author, read_type="r")

        if str(file_data[-1]) != str(list_author_info):
            # 要写入的数据
            data_to_write = "\n=============================\n" \
                            "时间：" + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + "\n" + \
                            "——————————————————————\n"  + \
                            str(list_author_info)

            self.object_Tool.do_file(file_path=file_Author, write_data=data_to_write, write_type="a+")

        # print("第三阶段")
        # file_data = self.object_Tool.read_file(file_path=file_Author, read_type="r")
        # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@")
        # print(file_data)
        # print("@@@@@@@@@@@@@@@@@@@@@@@@@@@")

    # 微信 / 点击用户头像
    def wechat_dianzan_user_head_image_action_flow(self, Start_Object):

        # print("")
        # print("点赞用户【动作流】")

        # 等待
        self.object_Tool.time_do_wait(seconds_to_wait=2)

        # @@@@@@@@@@@@@@@@@@@@@@@@
        # 已经到达【用户信息页】
        # @@@@@@@@@@@@@@@@@@@@@@@@
        self.wechat_user_info_page_analyze()

        # @@@@@@@@@@@@@@@@@@@@@@@@
        # 返回【之前的画面】 / 退出【用户信息页】
        # @@@@@@@@@@@@@@@@@@@@@@@@
        self.object_Appium.appium_driver_object.keyevent(4)

    # 微信【用户信息页】 / 分析
    def wechat_user_info_page_analyze(self):

        # 宣告
        # print("==============")
        # print("【用户信息页】分析")
        # print("==============")

        ListView_Object = self.object_Appium.appium_find_element_by_key_value(
            key="class",
            value="android.widget.ListView"
        )

        # @@@@@@@@@@@@@@@@@@@@@@@@
        Pure_Words = ListView_Object.find_elements_by_class_name("android.widget.TextView")

        # -- 属性
        Pure_Words_len = len(Pure_Words)

        # 显示
        # self.object_Appium.appium_elements_display(Start_Object=Pure_Words)

        # 变量
        current_dianzan_user_info = []

        if Pure_Words is not None:
            Pure_Words_len_cursor = 1
            for Pure_Words_len in range(Pure_Words_len):
                Pure_Words_in_for_loop = None
                while Pure_Words_in_for_loop is None:
                    try:
                        ListView_Object_in_for_loop = self.object_Appium.appium_find_element_by_key_value(
                            key="class",
                            value="android.widget.ListView"
                        )
                        Pure_Words_in_for_loop = ListView_Object_in_for_loop.find_elements_by_class_name("android.widget.TextView")

                    except Exception as excp:
                        pass

                Pure_Words_item = self.object_Appium.appium_find_element_in_set_with_sequence_v2(
                    Object_Set=Pure_Words_in_for_loop,
                    which_one=Pure_Words_len_cursor
                )

                Pure_Words_item_text = self.object_Appium.appium_element_get_attribute_TEXT(Pure_Words_item)

                if "昵称" in Pure_Words_item_text:
                    current_dianzan_user_info.append(Pure_Words_item_text)
                if "微信号" in Pure_Words_item_text:
                    current_dianzan_user_info.append(Pure_Words_item_text)
                if "地区" in Pure_Words_item_text:
                    current_dianzan_user_info.append(Pure_Words_item_text)

                # 自增
                Pure_Words_len_cursor = Pure_Words_len_cursor + 1

        # 显示当前【点赞用户的信息】
        print("当前点赞用户的【信息】：" + str(current_dianzan_user_info))

        # 追加到点赞用户的总列表
        # Old
        # self.dianzan_write_data = self.dianzan_write_data + "\n%%%%%%%%%%%%%%\n" + str(current_dianzan_user_info)

        # New
        # 写入文件
        self.object_Tool.do_file(
            file_path=self.path_wechat_pc_finally_file,
            write_data="\n%%%%%%%%%%%%%%\n" + str(current_dianzan_user_info),
            write_type='a'
        )

        # @@@@@@@@@@@@@@@@@@@@@@@@

    # 微信【图片或视频】 / 保存阶段 / 动作流
    def wechat_pic_or_video_action_flow(self, Start_Object, click_type):

        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 第一次
        # print("【保存】 / 1 / 从【详情页】到【预览】")
        Start_Object.click()

        # 等待
        self.object_Tool.time_do_wait(seconds_to_wait=3)
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 第二次
        # print("【保存】 / 2 / 保存")
        target_element_class = ""

        if click_type == "视频":
            target_element_class = "android.view.View"
        if click_type == "图片":
            target_element_class = "com.tencent.mm.ui.mogic.WxViewPager"

        # print(target_element_class)

        click_2_object = self.object_Appium.appium_find_element_by_key_value(
            key="class", value=target_element_class
        )
        TouchAction(self.object_Appium.appium_driver_object).long_press(click_2_object).perform()
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 第三次
        # print("【保存】 / 3 / 长按")
        click_3_object = None

        if click_type == "图片":
            patter_string = "//*/android.widget.TextView[@text='保存图片']/parent::android.widget.LinearLayout" \
                            "/parent::android.widget.RelativeLayout/parent::android.widget.LinearLayout"
            click_3_object = self.object_Appium.appium_find_element_by_xpath(
                str_xpath=patter_string,
                one_or_more="one"
            )

        if click_type == "视频":
            patter_string = "//*/android.widget.TextView[@text='保存视频']/parent::android.widget.LinearLayout" \
                            "/parent::android.widget.RelativeLayout/parent::android.widget.LinearLayout"
            click_3_object = self.object_Appium.appium_find_element_by_xpath(
                str_xpath=patter_string,
                one_or_more="one"
            )

        click_3_object.click()

        # 等待
        self.object_Tool.time_do_wait(seconds_to_wait=5)
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        # 第四次 / 返回
        # print("【保存】 / 4 / 返回")
        self.object_Appium.appium_driver_object.keyevent(4)
        # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

# </editor-fold>

# 入口函数
if __name__ == "__main__":

    # 宣告
    print("Python：微信")

    # 微信
    run_wechat = class_WeChat()
    run_wechat.wechat_launch(session_keep=True)
    # run_wechat.wechat_login()
    # run_wechat.wechat_moment(someone_name="你要爬取的微信号码")
    run_wechat.wechat_moment(someone_name="你要爬取的微信号码")
    run_wechat.wechat_moment_single_page_and_swipe()

# 结束